是否有完全符合 C++ 的标准?实施?
因此,我正在使用 GCC 尝试 C++0x 的一些功能,但我也想确保代码可以使用标准 C++ 编译器进行编译。因此,我在没有要求的情况下使用 __cplusplus 宏和 ifdefs 来排除 C++0x 代码。
我发现__cplusplus的值不是199711L,而是1!经过一番谷歌搜索后,我发现这个< /a> 其中表示 GCC 不是完全一致的实现。
有没有完全符合要求的实现?我知道 clang、gcc 和 msvc。 GCC 不是一个完全一致的实现,clang 和 msvc 是吗?
So I was trying out some features of C++0x using GCC, but I also wanted to make sure the code could be compiled with a standard C++ compiler. So I was playing around with the __cplusplus macro with ifdefs to exclude C++0x code when it wasn't asked for.
I found that the value of __cplusplus wasn't 199711L, it was 1! After a little bit of googling, I found this where it says GCC isn't a fully conforming implementation.
Are there any fully conforming implementations? I know of clang, gcc, and msvc. GCC isn't a fully conforming implementation, are clang and msvc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信 Comeau 完全符合要求。他们甚至实现了模板导出。
更重要的是,您可以在线尝试,这听起来对您正在做的事情会有帮助。
I believe Comeau is fully conforming. They even implemented template export.
And what's more, you can try it online, which sounds like it would help with what you're working on.
不。有可能有一个符合标准的编译器,但语言极其复杂。在编译器编写者努力工作的语言中存在一些极端情况、含糊之处,有时甚至是彻底的矛盾。
确保您的代码符合标准的最佳方法是对其进行大脑编译,因为您可以验证事物是否符合标准。当然,这取决于你是否能够充分理解该标准;是否有人能做到这一点是一个全新的问题。 ;)
No. It's possible to have a conforming compiler, but the language is extremely complex. There are corner-cases, ambiguities, and sometimes outright contradictions in the language that compiler writers struggle to get working.
The best way to make sure your code is standards-compliant is to brain-compile it, because you can verify things match the standard. Of course, this hinges on your ability to fully understand the standard; and whether or not any person can do that is an entirely new question. ;)
由于实现导出关键字的复杂性过高,除 Comeau 之外的任何编译器在不久的将来都不太可能完全兼容。有关原因,请参阅为什么我们负担不起导出。
It is unlikely that any compilers other than Comeau will be fully compliant in the near future due to the prohibitive complexity of implementing the export keyword. For reasons why, see Why We Can't Afford Export.