Pre-Defined Macros

Pre-Defined Macros

All C/C++ compilers define the following macros:

 __DATE__ //a literal containing the compilation date in the form "Apr 13 1998"__TIME__ //a literal containing the compilation time in the form "10:01:07"__FILE__ //a literal containing the name of the source file being compiled__LINE__ //a decimal integer containing the current line number in the source file

In addition, a C++ compiler defines the following macro:

 __cplusplus  //useful for combining  legacy C code with C++

And an ANSI conforming C compiler defines the following macro:

 __STDC__ //useful when one has to test whether the current compiler is ANSI C compatible

These macros can be useful for debugging and issuing diagnostic messages:

 if(isSuccessful == false){	 printf("failed to open transaction; error occurred at line %d in file %s", __LINE__,__FILE__);}

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist