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__);}
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: