编译器预定义宏概述

1 概念

Predefined Macros

The 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__ 扩展为整型常量,描述编译器的修正版本号; 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值