我在阅读Windows Research Kernel(WRK) 1.2中的源代码时遇到了这个预处理器定义:
#define assert(exp) ((void) 0)
Run Code Online (Sandbox Code Playgroud)
这段代码有什么作用?为什么定义?
为了扩展bdonlan所说的内容,宏不扩展空的原因是因为如果它确实如此,那么类似于:
assert(something) // oops, missed the semi-colon
assert(another_thing);
Run Code Online (Sandbox Code Playgroud)
将在发布模式下编译,但不在调试模式下编译.原因((void) 0)不仅仅是0防止"无效声明"警告(或MSVC称之为的任何警告).
| 归档时间: |
|
| 查看次数: |
5741 次 |
| 最近记录: |