首页  

c/c++标准预定义宏     所属分类 c 浏览量 633
标准预定义宏
The standard predefined macros are specified by the relevant language standards, 
so they are available with all compilers that implement those standards. 
Older compilers may not provide all of them. 
Their names all start with double underscores.

__DATE__      进行预处理的日期(Mmm dd yyyy 形式的字符串,如 Sep 10 2021 )
__FILE__      当前源代码文件名 详细路径 
__LINE__      当前源代码行号 整数
__TIME__      源文件编译时间,格式  hh:mm:ss
__func__      当前所在函数名,较高版本中支持
__FUNCTION__  当前所在函数名

___cplusplus   编译c++版本号 long int


 预定义宏 __cplusplus  

#include "iostream"
int main(){
  std::cout << __cplusplus << std::endl;
  
  std::cout << "__DATE__ "<< __DATE__ << std::endl;
  std::cout << "__TIME__ "<< __TIME__ << std::endl;
  std::cout << "__FILE__ "<< __FILE__ << std::endl;
  std::cout << "__LINE__ "<< __LINE__ << std::endl;
  std::cout << "__FUNCTION__ "<< __FUNCTION__ << std::endl;
  std::cout << "__func__ "<< __func__ << std::endl;
  
  return 0;
}

上一篇     下一篇
C/C++预编译指令

C C++ 宏定义 # 与 ##

预定义宏 __cplusplus

c++ 结构体例子

c++ 面向对象 例子

C++11 智能指针