是否有可能关闭的支持和QUOT;和" /"或QUOT;在海湾合作委员会的布尔运算符的使用情况? [英] Is it possible to turn off support for "and" / "or" boolean operator usage in gcc?

查看:128
本文介绍了是否有可能关闭的支持和QUOT;和" /"或QUOT;在海湾合作委员会的布尔运算符的使用情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GCC似乎允许和/或被用来代替与&&放大器; /||在C ++中code;但是,如我所料,很多编译器(特别是MSVC 7)不支持这一点。事实上,GCC允许这已经造成了一定的烦恼,对于我们,我们有不同的开发人员在多种平台上,有时在同一code基工作,这些错误的人来回切换Python和C之间溜进++发展。

GCC seems to allow "and" / "or" to be used instead of "&&" / "||" in C++ code; however, as I expected, many compilers (notably MSVC 7) do not support this. The fact that GCC allows this has caused some annoyances for us in that we have different developers working on the same code base on multiple platforms and occasionally, these "errors" slip in as people are switching back and forth between Python and C++ development.

在理想情况下,我们都记得使用适当的语法,但对于那些情况下,我们偶尔会陷入困境,那将是非常好的,如果GCC不让它滑动。任何人有任何的方法想法呢?

Ideally, we would all remember to use the appropriate syntax, but for those situations where we occasionally mess up, it would be really nice if GCC didn't let it slide. Anybody have any ideas on approaches to this?

如果与和或只是#define语句然后我使用GCC的时候可以和#undef,但我担心这更可能内置到编译器在更根本的层面。

If "and" and "or" are simply #defines then I could #undef when using GCC but I worry that it is more likely built into the compiler at more fundamental level.

感谢。

推荐答案

他们是C ++标准的一部分,例如见的这个StackOverflow的答案(它引用的是标准的相关部分)。

They are part of the C++ standard, see for instance this StackOverflow answer (which quotes the relevant parts of the standard).

在同样的问题另一个答案提到如何做相反的:使他们在工作MSVC

Another answer in the same question mentions how to do the opposite: make them work in MSVC.

要在GCC禁用它们,使用 -fno-运营商名称 。需要注意的是,通过这样做,你实际上切换到C ++的一个非标准的方言,还有就是你写出来code这可能不是正确编译上符合标准的编译器(例如风险,如果声明与通常会被保留的名称)的变量。

To disable them in GCC, use -fno-operator-names. Note that, by doing so, you are in fact switching to a non-standard dialect of C++, and there is a risk that you end up writing code which might not compile correctly on standard-compliant compilers (for instance, if you declare a variable with a name that would normally be reserved).

这篇关于是否有可能关闭的支持和QUOT;和" /"或QUOT;在海湾合作委员会的布尔运算符的使用情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆