Compiler Directive to List Defined Macros?

Neil Booth
Fri Jun 30 01:36:00 GMT 2000

Ross Combs wrote:-

> Hmm.  That is how I originally tried to use it.  It is also annoying that
> I couldn't find a way to stringize __LINE__ and then concatenate it to
> __FILE__.  But such things can be worked around.

You mean to get output like "\"myfile.c\": 200"?  If so, the following
should work:

#define str(x) #x
#define xstr(x) str(x)
xstr(__FILE__: __LINE__)

Or if you want "myfile.c: 200", i.e. without the inner quotes, try

__FILE__ ": " xstr(__LINE__)

If you don't understand why this works, info cpp should help.  If it
doesn't, please help us to improve the docs!


More information about the Gcc mailing list