-Werror=c++-compat odd behavior

tdwrk@barachs.net tdwrk@barachs.net
Sun Nov 25 13:08:00 GMT 2018


This version of gcc:

 

$ gcc --version

gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

 

Plus this three-liner:

 

#define badname im-not-happy

#define initializer(a) #a

 

char *only_a_string = initializer(badname);

 

Produces:

 

$ gcc -c -Werror=c++-compat /tmp/foo.c

/tmp/foo.c:1:20: error: identifier "not" is a special operator name in C++
[-Werror=c++-compat]

#define badname im-not-happy

                    ^

cc1: some warnings being treated as errors

 

This seems pretty odd... Can someone explain what's going on?

 

Thanks... Dave Barach



More information about the Gcc-help mailing list