Cross-platform development and serialization (predefined macros under the c99 Standard)

Source: Internet
Author: User
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.


_ Date _ Date of preprocessing (string text in the form of "Mmm dd YYYY)

_ File _ represents the string Text of the current source code file name

_ Line _ represents the integer constant of the row number in the current source code.

_ Time _ source file Compilation Time in the format of "HH: mm: SS"

_ FUNC _ the current function name // added to c99, which is not supported by some Compilers


It is useful for macros such as _ file __,__ line __,__ func _ in program debugging, 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.", _ file __);

Printf ("the date is % S.", _ date __);

Printf ("the time is % S.", _ time __);

Printf ("this is line % d.", _ line __);

Printf ("this function is % S.", _ FUNC __);

Why_me ();

Return 0;



Void why_me ()


Printf ("this function is % s", _ FUNC __);

Printf ("the file is % S.", _ file __);

Printf ("this is line % d.", _ 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: 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.