Besides __LINE__ and __FILE__, are there other useful pre-defined macros, like __FUNCTION_NAME__?
If not, but you know of other cool/useful defined macros (especially for debugging purposes), I’d love to hear about them.
Some have asked about platform: I’m using gcc/g++ on MacOSX.
I can find the following (descriptions from C99 draft, but they are available in C89 too I think):
__DATE__: The date of translation of the preprocessing translation unit: a characterstring literal of the form “Mmm dd yyyy”, where the names of the
months are the same as those generated by the
asctimefunction, and thefirst character of dd is a space character if the value is less than 10. If the
date of translation is not available, an implementation-defined valid date
shall be supplied.
__TIME__: The time of translation of the preprocessing translation unit: a characterstring literal of the form “hh:mm:ss” as in the time generated by the
asctimefunction. If the time of translation is not available, animplementation-defined valid time shall be supplied.
For the current function name, C99 defines
__func__, but__FUNCTION_NAME__is not a standard macro. In addition,__func__is not a macro, it’s a reserved identifier (6.4.2.2p1):If you’re looking for something that’s platform-specific: here’s a list of gcc’s common predefined macros. I like
__COUNTER__, which is a unique, sequential integer starting at 0. I think__INCLUDE_LEVEL__is cool too, but not sure if I can think of a use for it yet :-).