Compiler Directive to List Defined Macros?

Ross Combs rocombs@cs.nmsu.edu
Thu Jun 29 08:18:00 GMT 2000


First, thanks for taking the time to explain this.

> > It kept acting like neither one was avaliable.  So I tried forcing it to use
> > __func__, and I got compile errors.  I though that was strange, so I tried
> > forcing it to use __PRETTY_FUNCTION__ and finally it worked.
> ...
>
> I don't think you can reliably use #ifdef on __func__ or
> __PRETTY_FUNCTION__.  This is because they're not macros.  They're
> predefined static variables in every function's scope.

I see.  I guess the capitalization of __PRETTY_FUNCTION__ and the similarity
to __LINE__ threw me off.  Obviously the preprocessor doesn't know about
functions.  But why not make it something like an implicit:

 #define __PRETTY_FUNCTION__ __pretty_function__

and then I could test for it, but more importantly it would follow traditional
capitalization rules.

> I believe that the new C standard specifies a standard way to do this,
> and that GCC now does it in the standard way.  I forget what the exact
> name is, perhaps __function__.

Hmm... I thought it was __func__.  That is why I tried using it in preference
to __PRETTY_FUNCTION__.  Do you know how you are suppossed to test for it?

> > (Also, I never got a response to my last email to this list about detecting
> > multiple side effects and issuing a warning... does anyone care?  Is it such
> > a horrible idea?)
>
> It's not a bad idea.  Perhaps you could submit a patch?

I wouldn't mind working on one but there is no patch yet.  I haven't signed
a copyright release form and that might be a problem.  I also want to discuss
which cases should be warned about but that is a subject for another email...

-Ross


More information about the Gcc mailing list