问题描述
虽然通过一些C头文件(特别是 STDARG.H
)看,我注意到一个非常奇特的行:
While looking through some c header files (specifically stdarg.h
), I noticed a very peculiar line:
#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L
奇怪的部分是 0 +
。零是添加剂身份;它是各种数学的人都有写空操作
的。
The strange part is the + 0
. Zero is the additive identity; it's one of the various math has of writing noop
.
在上面的preprocessor声明的目的是什么不加零?我知道,有的摆在那里,但是这只是似乎是可笑的。
What purpose does adding zero have in the above preprocessor statement? I know that there's all sorts of weird preprocessor magic out there, but this just seems ridiculous.
推荐答案
这如果 __ __ STDC_VERSION
定义为避免了preprocessor语法错误
空的令牌(例如,用的#define __STDC_VERSION __
)。
That avoids a preprocessor syntax error if __STDC_VERSION__
is defined as anempty token (e.g. with #define __STDC_VERSION__
).
(感谢延Gustedt您指出我的回答的第一个版本是错误的。)
(Thanks to Jens Gustedt for pointing out that the first version of my answer was wrong.)
这篇关于在C preprocessor声明添加零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!