Leiji said:
I am curious if there are any pre-defined varables (constants?)
in C? I saw some code with __LINE__, __FILE__, etc. Are those
located in some include files?
No. You should look these things up in the standard. From N869:
6.10.8 Predefined macro names
[#1] The following macro names shall be defined by the
implementation:
__LINE__ The presumed line number (within the current source
file) of the current source line (a decimal
constant).137)
__FILE__ The presumed name of the current source file (a
character string literal).137)
__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 implementation-defined valid date
shall be 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 shall be
supplied.
__STDC__ The decimal constant 1, intended to indicate a
conforming implementation.
__STDC_VERSION__ The decimal constant 199901L.138)
[#2] The following macro names are conditionally defined by
the implementation:
__STDC_ISO_10646__ A decimal constant of the form yyyymmL
(for example, 199712L), intended to
indicate that values of type wchar_t are
the coded representations of the
characters defined by ISO/IEC 10646,
along with all amendments and technical
corrigenda as of the specified year and
month.
__STDC_IEC_559__ The decimal constant 1, intended to
indicate conformance to the
specifications in annex F (IEC 60559
floating-point arithmetic).
__STDC_IEC_559_COMPLEX__ The decimal constant 1, intended to
indicate adherence to the specifications
in informative annex G (IEC 60559
compatible complex arithmetic).
[#3] The values of the predefined macros (except for
__LINE__ and __FILE__) remain constant throughout the
translation unit.
[#4] None of these macro names, nor the identifier defined,
shall be the subject of a #define or a #undef preprocessing
directive. Any other predefined macro names shall begin
with a leading underscore followed by an uppercase letter or
a second underscore.
____________________
136An implementation is not required to perform macro
replacement in pragmas, but it is permitted except for in
standard pragmas (where STDC immediately follows pragma).
If the result of macro replacement in a non-standard
pragma has the same form as a standard pragma, the
behavior is still implementation-defined; an
implementation is permitted to behave as if it were the
standard pragma, but is not required to.
137The presumed line number and source file name can be
changed by the #line directive.
138This macro was not specified in ISO/IEC 9899:1990 and was
specified as 199409L in ISO/IEC 9899/AMD1:1995 |