Some predefined Macros in the c Standard

Source: Internet
Author: User

Some predefined Macros in the c Standard
From: http://www.wangchao.net.cn/bbsdetail_149674.html


Some predefined macros are specified in the C standard and are often used in programming. The following table lists some predefined macros that are frequently used.
Macro
Meaning
_ Date __
Date of preprocessing (string text in the form of "Mmm dd YYYY)
_ File __
Represents the current Source code String Text of the file name
_ Line __
Indicates the Current Source Code Integer constant of the row number in
_ Time __
Source File Compilation Time, in the format of "HH: mm: SS"
_ FUNC __
Current function name

For macros such as _ file __,__ line __,__ func _, Program It is very useful, because you can easily know the row of the file to which the program runs and the function.

The following example prints the predefined macros.
# Include <stdio. h>
# Include <stdlib. h>
Void why_me ();
Int main ()
{
Printf ("the file is % S. \ n", _ file __);
Printf ("the date is % S. \ n", _ date __);
Printf ("the time is % S. \ n", _ time __);
Printf ("this is line % d. \ n", _ line __);
Printf ("this function is % S. \ n", _ FUNC __);

Why_me ();

Return 0;
}
Void why_me ()
{
Printf ("this function is % s \ n", _ FUNC __);
Printf ("the file is % S. \ n", _ file __);
Printf ("this is line % d. \ n", _ line __);
}

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.