Compiler Directive to List Defined Macros?

Martin v. Loewis
Thu Jun 29 13:44:00 GMT 2000

> Ah.  But I'm getting version 199409 even though __func__ is defined...
> Was there a C94 standard?  Was C9X released as a standard or is it still
> in development?

No, there was an Amendment 1 to ISO 9899:1989, which was issued in
1994. That said implementations conforming to that ammendment should
define this value. Your implementation probably does not define the
1999 value, as it probably can't claim full conformance, yet. As a
result, you either need to specifically check for the version of the
compiler (as opposed to the version of the language), or just not use

Please note that the implementation can rightfully define __func__ and
still claim conformance to C89+Amd1, as that name is in the
implementation-reserved namespace.

> > The proper way of testing for these is to write
> >
> > #ifdef __GNUC__
> >
> > in which case you can use either one.
> So __PRETTY_FUNCTION__ has existed for a long time in gcc?  I can trust
> that even old copies will support this?

Yes. I could check when it was first introduced - but so could you.
Then you could define a reliable test based on the values of __GNUC__
and __GNUC_MINOR__

> In my reply to Geoff I noted one way to make it work.  It isn't needed
> as you point out there are other ways to detect these things.  Is it
> standard to make function names all uppercase though?

Well, these aren't function names, either. __func__ is a variable
name, so C99 followed the typical style for such names. When
__FUNCTION__ was first introduced, it was "magic" - a named string
literal (*). It was the only one of its kind, so it did not have to follow
any convention. Since it was anticipated that it is used together with
__FILE__ and __LINE__, it was given the same appearance.


(*) It still is, and some people claim that __func__ should have been
one of these, also, to allow concatenation as in

  __FILE__ ":" __FUNCTION__

More information about the Gcc mailing list