Skip to main content
With >= g++-10 users might want to first try -std=c++20
Source Link

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.

It is quite essential to use the -pedantic flag.

I would only add, that with the current standard it is advisable to use something similar to:

-std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors

Where:

  • -std=c++17 tells it to adhere to the revision of the C++ standard, published in 2017, you can read 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, 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.

It is quite essential to use the -pedantic flag.

With >= g++-10, the current standard preview, it is advisable to first try something similar to:

-std=c++20 -Wall -Wextra -Werror -Wpedantic -pedantic-errors

Where:

  • -std=c++20 tells it to adhere to the revision of the C++ standard, is expected to be published in 2020, you can read 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; 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.

Commonmark migration
Source Link

It is quite essential to use the -pedantic flag.

I would only add, that with the current standard it is advisable to use something similar to:

-std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors

Where:

  • -std=c++17 tells it to adhere to the revision of the C++ standard, published in 2017, you can read 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.

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, 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++.

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.

    -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.

It is quite essential to use the -pedantic flag.

I would only add, that with the current standard it is advisable to use something similar to:

-std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors

Where:

  • -std=c++17 tells it to adhere to the revision of the C++ standard, published in 2017, you can read 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, 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.

It is quite essential to use the -pedantic flag.

I would only add, that with the current standard it is advisable to use something similar to:

-std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors

Where:

  • -std=c++17 tells it to adhere to the revision of the C++ standard, published in 2017, you can read 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, 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.

changed to already published std=c++17 + citations are more user friendly now
Source Link

I agree with colleagues. It is quite essential to use the -pedantic flag.

I would only add, that with the current standard it is advisable to use something similar to:

-std=c++14std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors

Where:

  • -std=c++14std=c++17 tells it to adhere to the revision of the C++ standard, published in 20142017, you can read 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.

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, 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++.

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 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.

I agree with colleagues. It is quite essential to use the -pedantic flag.

I would only add, that with current standard it is advisable to use something similar to:

-std=c++14 -Wall -Wextra -Werror -Wpedantic -pedantic-errors

Where:

  • -std=c++14 tells it to adhere to the revision of the C++ standard, published in 2014

  • -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, 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.

It is quite essential to use the -pedantic flag.

I would only add, that with the current standard it is advisable to use something similar to:

-std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors

Where:

  • -std=c++17 tells it to adhere to the revision of the C++ standard, published in 2017, you can read 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, 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.

Source Link
Loading