1 概念
Predefined MacrosThe compiler recognizes six predefined ANSI C macros (see Table 1.1), and the Microsoft C++ implementation
provides several more (see Table 1.2). These macros take no arguments and cannot be redefined. Their value
(except for __LINE__ and __FILE__) must be constant throughout compilation. Some of the predefined macros
listed below are defined with multiple values. Their values can be set by selecting the corresponding menu
option in the Visual C++ development environment, or by using a command-line switch. See the tables below f
or more information.
2 GCC编译器
Ø __FILE__ 扩展为使用该宏的文件名;
Ø __LINE__ 扩展为使用该宏的源码所在的行号;
Ø __func__ 同 __FUNCTION__ __FUNCTION__ 当前函数的名称;
Ø __DATE__ 扩展为一个字符串,描述编译程序时预处理器运行时的日期; 格式为:"Feb 12 1996";
Ø __TIME__ 扩展为一个字符串,描述编译程序时预处理器运行时的时间; 格式为:"23:59:01";
Ø __cplusplus 该宏只有在C++编译器被使用时才会定义。你可以使用这个宏 来测试一个头文件当前是被C编译器还是被C++编译器编译;
Ø __VERSION__ 扩展为一个字符串,描述所使用编译器的完整版本信息;
Ø __GNUC__ 扩展为整型常量,描述编译器的主版本号;
Ø __GNUC_MINOR__ 扩展为整型常量,描述编译器的次版本号;
Ø __GNUC_PATCHLEVEL__ 扩展为整型常量,描述编译器的修正版本号;