Macros active in error messages

Jonathan Wakely jwakely.gcc@gmail.com
Sun Nov 22 18:16:39 GMT 2020


On Sun, 22 Nov 2020, 15:35 emre brookes, <brookes@uthscsa.edu> wrote:

> I was compiling a project and received an odd message that took some
> digging.
> e.g.
>
> file.cpp:#:#: error: expected unqualified-id before numeric constant
> # | if ( inttype == MyClass::ERROR )
>                               ^~~~~
> where MyClass::ERROR is an enum.
>
> Took some digging to find out ERROR was somewhere #define'd and the cure
> was to #undef ERROR
> Could never find out *where* it was defined - recursively searched all
> include files of the project and /usr/include etc.
>


I know it's not your main question, but ...

g++ -E -dD foo.cc will show all the macro definitions.


More information about the Gcc-help mailing list