[C++]c++预定义宏

Main.cpp

  
  
  
  
  1. #include <stdlib.h> 
  2. #include <iostream> 
  3. /* 
  4. * c++预定义宏 
  5. * __LINE__     当前行在源代码中的行号 
  6. * __FILE__     当前代码在源文件中的文件名 
  7. * __DATE__     当前源代码编译时的日期 
  8. * __TIME__     当前源代码编译时的时间 
  9. * __FUNCTION__ 当前行所在函数的函数名 
  10. */ 
  11.  
  12. using namespace std; 
  13. int main(int argc, char *argv[]){ 
  14.     cout << "date:" << __DATE__ << endl; 
  15.     cout << "time:" << __TIME__ << endl; 
  16.     cout << "file:" << __FILE__ << endl; 
  17.     cout << "line:" << __LINE__ << endl; 
  18.     cout << "function:" << __FUNCTION__ <<endl; 
  19.     system("pause"); 
  20.     return EXIT_SUCCESS; 

打印结果:

你可能感兴趣的:(c++预定义宏)