The specific one you're looking for is called __func__
, but it's not exactly a macro, since it's meaning changes depending on where it's seen. It is useful, however, and does look like a macro.
My favorite macro at the moment is __STDC_VERSION__
because it lets me do this:
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
# define inline
# define register
# if __GNUC__ >= 2 || _MSC_VER >= 1300
# define __func__ __FUNCTION__
# else
# define __func__ "<unknown>"
# endif
#endif
Now you can use the C99 keywords inline
, register
, and __func__
to declare things without having to worry about whether or not the compiler you're using supports that C99 functionality! In reality, the bit for inline
is more complex since some compilers define __inline
and other such silliness, but you get the general idea.
Also, a useful list of pre-defined macros for identifying compilers, operating systems, and architectures can be found here.