From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ross Combs 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 Message-id: <200006291528.JAA27595@quito.cs.nmsu.edu> X-SW-Source: 2000-06/msg00753.html > > 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