Enforcing the C++98 standard in gcc

好久不见. 提交于 2019-12-10 14:44:28

问题


I have a school assignment that should be written in C++98-compliant code. How can I force g++ to accept only code that follows this standard? Will -std=c++98 do the trick or do I need to add additional flags?


回答1:


Per GCC's documentation on standards:

The original ISO C++ standard was published as the ISO standard (ISO/IEC 14882:1998) and amended by a Technical Corrigenda published in 2003 (ISO/IEC 14882:2003). These standards are referred to as C++98 and C++03, respectively. GCC implements the majority of C++98 (export is a notable exception) and most of the changes in C++03. To select this standard in GCC, use one of the options -ansi, -std=c++98, or -std=c++03; to obtain all the diagnostics required by the standard, you should also specify -pedantic (or -pedantic-errors if you want them to be errors rather than warnings).

Therefore, you should specify -std=c++98 -pedantic if you really want to ensure standards compliance.



来源:https://stackoverflow.com/questions/12606713/enforcing-the-c98-standard-in-gcc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!