Why does GCC not complain about _Bool in c89 mode? -
why following command produce no warnings or errors, though _bool not part of c89?
$ echo "_bool x;" | gcc -x c -c -std=c89 -pedantic -wall -wextra - for comparison, changing _bool bool results in error:
$ echo "bool x;" | gcc -x c -c -std=c89 -pedantic -wall -wextra - <stdin>:1:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘x’ this happens on cygwin [gcc (gcc) 4.5.3] , linux [gcc (gcc) 4.1.2 20080704 (red hat 4.1.2-54)].
using _bool in c89 compiler invokes undefined behavior because use identifier starting underscore , upper case letter. don't have paper copy of c89 handy, expect same c99 7.1.3:
— identifiers begin underscore , either uppercase letter or underscore reserved use.
one permissible undefined behavior accepting _bool without diagnostic. gnu extension.
of course, bool doesn't fall implementation namespace, must diagnosed unless declared.
Comments
Post a Comment