[lug] C++ question, without buying expensive doc.s

Tkil tkil at scrye.com
Mon Jan 10 17:14:05 MST 2005


>>>>> "Paul" == Paul E Condon <pecondon at mesanetworks.net> writes:

Paul> I'm looking for information about predefined names in C++. 

Out of curiosity, what are you looking for this info for?

Note that normal compilation modes usually have a huge number of other
predefined macros (OS, architecture, compiler, etc).  Most compilers
have listings of what they set, or they can be dumped at runtime.

Paul> I'm hoping for a link to a place that the responder considers
Paul> reliable.

You can get the official C++ spec for about 20$ online; if you're
going to be doing detailed language-lawyer level stuff, it's well
worth the investment.  In this particular case, here is the relevant
bit:

| 16 Preprocessing directives
| 
|   16.8 Predefined macro names [cpp.predefined]
| 
|    1 The following macro names shall be defined by the
|    implementation:
| 
|      __LINE__ The line number of the current source line (a
|               decimal constant).
| 
|      __FILE__ The presumed name of the source file (a character
|               string literal).
| 
|      __DATE__ The date of translation of the source file (a
|               character string literal of the form "Mmm dd yyyy",
|               where the names of the months are the same as those
|               generated by the asctime function, and the first
|               character of dd is a space character if the value is
|               less than 10). If the date of translation is not
|               available, an implementationdefined valid date is
|               supplied.
| 
|      __TIME__ The time of translation of the source file (a
|               character string literal of the form "hh:mm:ss" as in
|               the time generated by the asctime function). If the
|               time of translation is not available, an
|               implementation defined valid time is supplied.
| 
|      __STDC__ Whether __STDC__ is predefined and if so, what its
|               value is, are implementation defined.
| 
|      __cplusplus The name __cplusplus is defined to the value
|                  199711L when compiling a C++ translation unit.
| 
|    2 The values of the predefined macros (except for __LINE__ and
|      __FILE__) remain constant throughout the translation unit.
| 
|    3 If any of the predefined macro names in this subclause, or the
|      identifier defined, is the subject of a #define or a #undef
|      preprocessing directive, the behavior is undefined.





More information about the LUG mailing list