Go to Google Groups Home    comp.lang.c
__FUNCTION__ ????

Kalle Olavi Niemitalo <k...@iki.fi>

sob...@eudoramail.com (Sobhan Vezzu) writes:
>          I understood that __FUNCTION__ is a preprocessor macro, which
> will substitute a file name. Similar to __FILE__ and __LINE__.

__FUNCTION__ is a GCC-specific extension.  Please read the node
"Function Names" in the GCC Info file or "Function Names as Strings"
in the printed manual; it's all explained there.

>          1) I have written a small code, only for __FUNCTION__ it
> prints as unknown why?

__FUNCTION__ is not a preprocessor macro, because the preprocessor
does not know about functions.

C99 has a similar identifier __func__, which isn't a preprocessor
macro either.

>          2) Where do I get a list of all the preprocessor macros.

If you're using GCC on Unix, you can do this:

  gcc -E -dM -xc /dev/null

i.e., preprocess an empty file as C and list all defined macros when
finished.  Many of those macros are not in any standard.