Enforcing the C++98 standard in gcc

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?


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.

链接地址: http://www.djcxy.com/p/86352.html

上一篇: 学习GCC / G ++编译器?

下一篇: 在gcc中执行C ++ 98标准