Pre-defined macros in VC++

  • 测试程序
#include "pch.h"
#include <iostream>
 
class Test
{
public:
    static void test_func() {
        std::cout << "__func__\n\t" << __func__ << std::endl;
        std::cout << "__FUNCTION__\n\t" << __FUNCTION__ << std::endl;
        std::cout << "__FUNCDNAME__\n\t" << __FUNCDNAME__ << std::endl;
        std::cout << "__FUNCSIG__\n\t" << __FUNCSIG__ << std::endl;
    }
 
    static void test_counter() {
        std::cout << "__COUNTER__\n\t" << __COUNTER__ << std::endl;
        std::cout << "__COUNTER__\n\t" << __COUNTER__ << std::endl;
        std::cout << "__COUNTER__\n\t" << __COUNTER__ << std::endl;
    }
};
 
int main()
{
    std::cout << "__FILE__\n\t" << __FILE__ << std::endl;
    std::cout << "__LINE__\n\t" << __LINE__ << std::endl;
    std::cout << "__DATE__\n\t" << __DATE__ << std::endl;
    std::cout << "__TIME__\n\t" << __TIME__ << std::endl;
    std::cout << "__TIMESTAMP__ \n\t" << __TIMESTAMP__ << std::endl;
    std::cout << "_INTEGRAL_MAX_BITS\n\t" << _INTEGRAL_MAX_BITS << std::endl;
    std::cout << "__COUNTER__\n\t" << __COUNTER__ << std::endl;
    Test::test_func();
    Test::test_counter();
}
  • 测试结果
__FILE__
        d:\home\consoleapplication1\main.cpp
__LINE__
        24
__DATE__
        Mar 13 2019
__TIME__
        13:55:00
__TIMESTAMP__
        Wed Mar 13 13:54:48 2019
_INTEGRAL_MAX_BITS
        64
__COUNTER__
        3
__func__
        test_func
__FUNCTION__
        Test::test_func
__FUNCDNAME__
        ?test_func@Test@@SAXXZ
__FUNCSIG__
        void __cdecl Test::test_func(void)
__COUNTER__
        0
__COUNTER__
        1
__COUNTER__
        2