It is quite essential to use the -pedantic
flag.
I would only addWith >= g++-10
, that with the current standard preview, it is advisable to usefirst try something similar to:
-std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors
-std=c++20 -Wall -Wextra -Werror -Wpedantic -pedantic-errors
Where:
-std=c++17std=c++20
tells it to adhere to the revision of the C++ standard, is expected to be published in 20172020, you can read more about it hereread more about it here.-Wall
tells it to:Enable all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in conjunction with macros, in other words, some set of warnings.
-Wextra
tells it to enable some more warnings,warnings; still not all.-Werror
tells it to make all warnings into errors.-Wpedantic
or just-pedantic
tells it to:Issue all the warnings demanded by strict ISO C and ISO C++; reject all programs that use forbidden extensions, and some other programs that do not follow ISO C and ISO C++.
-pedantic-errors
tells it to give an error whenever the base standard (see -Wpedantic) requires a diagnostic.
This set is usually useful not only for beginners, as they will gradually learn each warning has it's potential for resulting in error, but also for normal use.
All warning options are described in detail here on the GNU/GCC page.