This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Compiler Directive to List Defined Macros?


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!

Neil.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]