LScarpinati

The C predefined macros

Dec 28th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.04 KB | None | 0 0
  1. /*
  2. __FILE__ - a string that holds the path/name of the compiled file;
  3. __LINE__ - an integer that holds the number of the current line number;
  4. __DATE__ - a string that holds the current system date;
  5. __TIME__ - a string that holds the current system time;
  6. __STDC__ - defined as the value '1' if the compiler conforms with the ANSI C standard;
  7. __cplusplus - determines if your compiler is in C or C++ mode. Usually used in headers.
  8. */
  9.  
  10.  
  11. #include <stdio.h>
  12.  
  13. void main(void)
  14. {
  15.     printf("The path/name of this file is %s\n", __FILE__);
  16.     printf("The current line is %d\n", __LINE__);
  17.     printf("The current system date is %s\n", __DATE__);
  18.     printf("The current system time is %s\n", __TIME__);
  19.     #ifdef __STDC__
  20.         printf("The compiler conforms with the ANSI C standard\n");
  21.     #else
  22.         printf("The compiler doesn't conform with the ANSI C standard\n");
  23.     #endif
  24.     #ifdef __cplusplus
  25.         printf("The compiler is working with C++\n");
  26.     #else
  27.         printf("The compiler is working with C\n");
  28.     #endif
  29. }
Advertisement
Add Comment
Please, Sign In to add comment