C++内置预定义宏

 

#include<iostream>

void func(void) {
    char ch3[100] =__FUNCTION__;  //返回当前函数名
    std::cout << ch3 << std::endl;
}

int main()
{
    char ch[250]= __FILE__;  //返回当前文件的全路径
    int n = __LINE__;  //返回当前行号
    char ch1[100] = __TIME__;  //返回当前系统时间
    char ch2[100] = __DATE__;
    char ch4[100] = __TIMESTAMP__; //当前系统时间戳
    std::cout << ch << std::endl;
    std::cout << n << std::endl;
    std::cout << ch1 << std::endl;
    std::cout << ch2 << std::endl;
    func();
    std::cout << ch4 << std::endl;

    return 0;
}

 

 

 

 

posted @ 2020-09-09 15:42  天子骄龙  阅读(160)  评论(0编辑  收藏  举报