public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ross Combs <rocombs@cs.nmsu.edu>
To: martin@loewis.home.cs.tu-berlin.de, rocombs@cs.nmsu.edu
Cc: gcc@gcc.gnu.org
Subject: Re: Compiler Directive to List Defined Macros?
Date: Thu, 29 Jun 2000 08:28:00 -0000	[thread overview]
Message-ID: <200006291528.JAA27595@quito.cs.nmsu.edu> (raw)

> > A few things seem to be missing though.  It doesn't show __FILE__, __LINE__,
> > __func__, or __PRETTY_FUNCTION__.  I understand these are a little different
> > since they are "dynamic", but it would be helpful to know which ones are
> > avaliable.
>
> The complete list can be found be combining those required by the
> standard with those documented in the GCC documentation, in particular
> in the section "Function Names".

Ok.  I admit to being guilty of not reading the info documents.  I really
prefer the man format, but I know it has limitations and is considered to
be historical baggage.  I'm still curious as to why they aren't listed.
(Except for __func__ and __PRETTY_FUNCTION__.)

> As Geoff explains, __func__ is not a preprocessor macro. Instead, it
> is an identifier. The proper way of testing for it is to write
>
> #if __STDC_VERSION__+0 >= 199901L
>
> since __func__ is defined by C99.

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?

> >  # ifdef __PRETTY_FUNCTION__
> >    /* code using __PRETTY_FUNCTION__ */
> > ...
>
> 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?

> No, that is not possible - the preprocessor has no way of knowing what
> the current function is. That's why they are identifiers, or string
> literals.

I understand that now.  I'm sorry for not figuring that out before.  It
still seems like __PRETTY_FUNCTION__ looks like a macro to me.

> > But is #2 "fixed" yet?
>
> It's not broken. It can't possibly work the way you expect it to
> work. Instead, you must use other tests in portable code.

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?

Thanks for showing me how to fix this.

-Ross

             reply	other threads:[~2000-06-29  8:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-29  8:28 Ross Combs [this message]
2000-06-29 13:44 ` Martin v. Loewis
  -- strict thread matches above, loose matches on Subject: below --
2000-06-30 14:34 Ross Combs
2000-06-29 15:49 Ross Combs
2000-06-30  1:36 ` Neil Booth
2000-06-29  8:18 Ross Combs
2000-06-29 11:38 ` Geoff Keating
2000-06-28 17:19 Ross Combs
2000-06-28 19:40 ` Geoff Keating
2000-06-29  0:39 ` Martin v. Loewis
2000-06-28  6:44 Bolan Meek
2000-06-28  7:27 ` Franz Sirl
2000-06-28  7:35   ` Bolan Meek
2000-06-28  7:56     ` Alexandre Oliva
2000-06-28  8:06       ` Bolan Meek
2000-06-28  8:14         ` Alexandre Oliva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200006291528.JAA27595@quito.cs.nmsu.edu \
    --to=rocombs@cs.nmsu.edu \
    --cc=gcc@gcc.gnu.org \
    --cc=martin@loewis.home.cs.tu-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).