What does a standard say about extending a C++ language and adding ‘non standard’ keywords? Do the keyword have to start with __ (double underscore) or can the be ‘regular’, meaning starting with a letter? If I would about to create extension to C++ and have a new keyword do I have to make it look like this:
__new_keyword
or can it be just simple:
new_keyword.
Thanks.
The standard says that identifiers with two underscores are reserved for the compiler. So if you want a safe way to add language extensions in your C++ compiler, that would be one way to do it. Be advised that if you’re just writing a pre-processor, the compiler you use may conflict with what you choose. But since the pre-processed code should be fairly simple, it shouldn’t be a problem.
You CAN do whatever you want, because it won’t be C++ and therefore does not have to conform to anything. However, if you want to keep conflicts with user-created names to a minimum, the standard says that identifiers that begin with two underscores are reserved by the C++ implementation, as are identifiers that begin with an underscore followed by a capital letter.
Note that this will only stop you from conflicting with user code. You can still conflict with your standard library implementation or whatever compiler you’re working with.