🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

"default" keyword

Started by
5 comments, last by gjl 10 years, 5 months ago

Hi,

I have noticed that "default" is considered as a reserved keyword, so you cannot use it for variable names, whereas in C++ it's "default:" that is reserved. Is there any way to change that? It is causing me trouble while converting existing c++ code into angelscript...

Advertisement

The keywords are part of the language. To modify the syntax by changing Angelscript it will technically be another language. So, as you can see, this may not be the best thing to do. Instead, can't you use another variable name like defaultPlayer or something like that?

It's eleventy billion times easier to rename your variable to something else than it is to change the language.
Are you saying that "default" is not a reserved keyword in C++? I think you are wrong.
int default = 5; // error: expected unqualified-id before ‘default’

Which compiler are you using? With VS2012 this compiles just fine.

I know it's not a big deal, I was simply asking :-)

I'm using GCC 4.7.

Hmm, seems to be an extra feature of Visual C++. Not standard C++.
http://connect.microsoft.com/VisualStudio/feedback/details/382138/c-default-keyword-can-be-used-as-identifier

this is a known issue with Visual C++ and it pretty much By-Design due to our need to support C++/CLI - specifically default properties.

Ah ok, thanks! Haden't tried with gcc yet. So I guess let's just forget about it then! :-)

This topic is closed to new replies.

Advertisement