I wrote a simple C program to test the availability of _Generic keyword.
int main() {
int _Generic;
}
I ran the program with gcc-5.3.1 and clang-3.8.0 compilers on Ubuntu.
Obviously this program generated an error when compiled in the latest c11 standard.
But, when compiled with -std=c90 and -std=c99 flags, it generated an error as well. Whereas, the _Generic keyword was only introduced in c11 standard.
Is it that the -std= flags behave differently? And is there a way to test the pure c90 and c99 standards?
EDIT:
I did run the same program with other identifiers which are not keywords as per c11 standard. Like:
int _Hello;
int _Gener;
And they compiled successfully without any errors or warnings. This is probably because of 7.1.3, which says
If the program declares or defines an identifier in a context in which it is reserved (other than as allowed by 7.1.4), or defines a reserved identifier as a macro name, the behavior is undefined
as said by @Art and @Lundin.
__or_<uppercase>, to be precise. - Sourav Ghosh__WOOZLEas a predefined macro for the new intrinsic___WOOZLE) could add features and allow code to use them while maintaining compatibility with older code via e.g.#ifndef __UNSPEC_CHOICE(x,y)#define __UNSPEC_CHOICE(x,y) x#endif. If a new compiler will interpret that as an intrinsic that expands to x or y, whichever is more efficient, code which is written to exploit that, but starts with the above#ifdef, could work on old or new compilers. - supercat