ifdef中的布尔值是“ #ifdef A&& B”与“ #if defined(A)&&定义(B)”? [英] Boolean in ifdef: is "#ifdef A && B" the same as "#if defined(A) && defined(B)"?
本文介绍了ifdef中的布尔值是“ #ifdef A&& B”与“ #if defined(A)&&定义(B)”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C ++中,是这样的:
In C++, is this:
#ifdef A && B
与以下内容相同:
#if defined(A) && defined(B)
?
I当时以为不是,但我无法与我的编译器(VS2005)有所区别。
I was thinking it wasn't, but I haven't been able to find a difference with my compiler (VS2005).
推荐答案
它们是不相同的。第一个无效(我在gcc 4.4.1中进行了测试)。错误消息是:
They are not the same. The first one doesn't work (I tested in gcc 4.4.1). Error message was:
test.cc:1:15:警告:#ifdef指令的
末尾有额外的令牌
test.cc:1:15: warning: extra tokens at end of #ifdef directive
如果要检查是否定义了多个内容,请使用第二个。
If you want to check if multiple things are defined, use the second one.
这篇关于ifdef中的布尔值是“ #ifdef A&& B”与“ #if defined(A)&&定义(B)”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文