C. predefined macros

Source: Internet
Author: User

_ DATE __

A String constant that indicates the date on which the Preprocessor executes. It contains 11 characters, for example, "Feb 12 1996". If the date is less than 10, add a space.

If GCC cannot determine the current DATE, a warning is generated during each compilation. __date _ is expressed "??? ?? ????".

_ TIME __

A String constant that indicates the time when preprocessing is performed. It contains 8 characters, for example, "23:59:01 ".

If GCC cannot determine the current time, a warning is generated at each compilation. __date _ is expressed "?? :?? :??".

_ FILE __

C String constant. The current source code file contains detailed paths, for example, "/usr/local/include/leo. c"

_ LINE __

A decimal integer constant that indicates the current row number.

 

_ FILE _ and _ LINE _ are useful when generating error information of the report program. They can mark the FILE and row number generated by the exception.

An # include directive changes the expansions of _ FILE _ and _ LINE _ to correspond to the specified ded 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 the line after the # include ).

# The line command also changes the values of _ FILE _ and _ LINE.

_ Func __

String, indicating the name of the current function, introduced in C99.

_ FUNCITON __

Same as _ func __, introduced by GCC.

Both _ func _ and _ FUNCITON _ are not macros, and the pre-processor does not know the name of the current function, however, like _ FILE _ and _ LINE _, it can be used for program debugging and exception reporting.

_ STDC __

If the value is 1, the compiler complies with ISO Standard C. This is not the case if the compiler uses gnu cpp instead of GCC. The pre-processor always follows the standard unless the-tradional-cpp option is used.

This macro is not defined when the-tradional-cpp option is used.

On some machines, when standard C is followed, it is defined as 1, instead of 0, so it is best to use # if _ STDC __,

Instead of using # ifdef _ STDC __.

_ Stdc1_version __

A long integer constant that indicates the c standard version number followed by the compiler. For example, yyyymmL, yyyy, and mm indicate the year and month of the version respectively.

Unless gnu cpp uses GCC, its implementation does not need to be accurate. For example, 199409L indicates the 1989C revised in 1994, which is currently supported by default. 199901L indicates C. Currently, it cannot be fully supported.

If-tradional-cpp is used or C ++ or Objective-C is compiled, this macro is not defined.

 

From sdtarena

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.