This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Compiler Directive to List Defined Macros?
- To: geoffk at cygnus dot com, rocombs at cs dot nmsu dot edu
- Subject: Re: Compiler Directive to List Defined Macros?
- From: Ross Combs <rocombs at cs dot nmsu dot edu>
- Date: Thu, 29 Jun 2000 09:18:38 -0600
- Cc: gcc at gcc dot gnu dot org
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