GNU Info

Info Node: (cpp-295.info)Standard Predefined

(cpp-295.info)Standard Predefined


Next: Nonstandard Predefined Prev: Predefined Up: Predefined
Enter node , (file) or (file)node

Standard Predefined Macros
..........................

   The standard predefined macros are available with the same meanings
regardless of the machine or operating system on which you are using
GNU C.  Their names all start and end with double underscores.  Those
preceding `__GNUC__' in this table are standardized by ANSI C; the rest
are GNU C extensions.

`__FILE__'
     This macro expands to the name of the current input file, in the
     form of a C string constant.  The precise name returned is the one
     that was specified in `#include' or as the input file name
     argument.

`__LINE__'
     This macro expands to the current input line number, in the form
     of a decimal integer constant.  While we call it a predefined
     macro, it's a pretty strange macro, since its "definition" changes
     with each new line of source code.

     This and `__FILE__' are useful in generating an error message to
     report an inconsistency detected by the program; the message can
     state the source line at which the inconsistency was detected.
     For example,

          fprintf (stderr, "Internal error: "
                           "negative string length "
                           "%d at %s, line %d.",
                   length, __FILE__, __LINE__);

     A `#include' directive changes the expansions of `__FILE__' and
     `__LINE__' to correspond to the included file.  At the end of that
     file, when processing resumes on the input file that contained the
     `#include' directive, the expansions of `__FILE__' and `__LINE__'
     revert to the values they had before the `#include' (but
     `__LINE__' is then incremented by one as processing moves to the
     line after the `#include').

     The expansions of both `__FILE__' and `__LINE__' are altered if a
     `#line' directive is used.  Note: Combining Sources.

`__DATE__'
     This macro expands to a string constant that describes the date on
     which the preprocessor is being run.  The string constant contains
     eleven characters and looks like `"Feb  1 1996"'.

`__TIME__'
     This macro expands to a string constant that describes the time at
     which the preprocessor is being run.  The string constant contains
     eight characters and looks like `"23:59:01"'.

`__STDC__'
     This macro expands to the constant 1, to signify that this is ANSI
     Standard C.  (Whether that is actually true depends on what C
     compiler will operate on the output from the preprocessor.)

     On some hosts, system include files use a different convention,
     where `__STDC__' is normally 0, but is 1 if the user specifies
     strict conformance to the C Standard.  The preprocessor follows
     the host convention when processing system include files, but when
     processing user files it follows the usual GNU C convention.

     This macro is not defined if the `-traditional' option is used.

`__STDC_VERSION__'
     This macro expands to the C Standard's version number, a long
     integer constant of the form `YYYYMML' where YYYY and MM are the
     year and month of the Standard version.  This signifies which
     version of the C Standard the preprocessor conforms to.  Like
     `__STDC__', whether this version number is accurate for the entire
     implementation depends on what C compiler will operate on the
     output from the preprocessor.

     This macro is not defined if the `-traditional' option is used.

`__GNUC__'
     This macro is defined if and only if this is GNU C.  This macro is
     defined only when the entire GNU C compiler is in use; if you
     invoke the preprocessor directly, `__GNUC__' is undefined.  The
     value identifies the major version number of GNU CC (`1' for GNU CC
     version 1, which is now obsolete, and `2' for version 2).

`__GNUC_MINOR__'
     The macro contains the minor version number of the compiler.  This
     can be used to work around differences between different releases
     of the compiler (for example, if gcc 2.6.3 is known to support a
     feature, you can test for `__GNUC__ > 2 || (__GNUC__ == 2 &&
     __GNUC_MINOR__ >= 6)').  The last number, `3' in the example
     above, denotes the bugfix level of the compiler; no macro contains
     this value.

`__GNUG__'
     The GNU C compiler defines this when the compilation language is
     C++; use `__GNUG__' to distinguish between GNU C and GNU C++.

`__cplusplus'
     The draft ANSI standard for C++ used to require predefining this
     variable.  Though it is no longer required, GNU C++ continues to
     define it, as do other popular C++ compilers.  You can use
     `__cplusplus' to test whether a header is compiled by a C compiler
     or a C++ compiler.

`__STRICT_ANSI__'
     GNU C defines this macro if and only if the `-ansi' switch was
     specified when GNU C was invoked.  Its definition is the null
     string.  This macro exists primarily to direct certain GNU header
     files not to define certain traditional Unix constructs which are
     incompatible with ANSI C.

`__BASE_FILE__'
     This macro expands to the name of the main input file, in the form
     of a C string constant.  This is the source file that was specified
     as an argument when the C compiler was invoked.

`__INCLUDE_LEVEL__'
     This macro expands to a decimal integer constant that represents
     the depth of nesting in include files.  The value of this macro is
     incremented on every `#include' directive and decremented at every
     end of file.  For input files specified by command line arguments,
     the nesting level is zero.

`__VERSION__'
     This macro expands to a string constant which describes the
     version number of GNU C.  The string is normally a sequence of
     decimal numbers separated by periods, such as `"2.6.0"'.

`__OPTIMIZE__'
     GNU CC defines this macro in optimizing compilations.  It causes
     certain GNU header files to define alternative macro definitions
     for some system library functions.  You should not refer to or
     test the definition of this macro unless you make very sure that
     programs will execute with the same effect regardless.

`__CHAR_UNSIGNED__'
     GNU C defines this macro if and only if the data type `char' is
     unsigned on the target machine.  It exists to cause the standard
     header file `limits.h' to work correctly.  You should not refer to
     this macro yourself; instead, refer to the standard macros defined
     in `limits.h'.  The preprocessor uses this macro to determine
     whether or not to sign-extend large character constants written in
     octal; see Note: The `#if' Directive.

`__REGISTER_PREFIX__'
     This macro expands to a string (not a string constant) describing
     the prefix applied to CPU registers in assembler code.  You can
     use it to write assembler code that is usable in multiple
     environments.  For example, in the `m68k-aout' environment it
     expands to the null string, but in the `m68k-coff' environment it
     expands to the string `%'.

`__USER_LABEL_PREFIX__'
     Similar to `__REGISTER_PREFIX__', but describes the prefix applied
     to user generated labels in assembler code.  For example, in the
     `m68k-aout' environment it expands to the string `_', but in the
     `m68k-coff' environment it expands to the null string.  This does
     not work with the `-mno-underscores' option that the i386 OSF/rose
     and m88k targets provide nor with the `-mcall*' options of the
     rs6000 System V Release 4 target.


automatically generated by info2www version 1.2.2.9