If I compile my C or C++ code with GCC, using -std=c99
or -std=c++11
or some other proper ISO standard rather than a GNU extension - will -Wpedantic
issue more warnings that I would usually get? e.g. With -W
, -Wall
or -Wall -Wextra
?
Yes, using -pedantic
makes GCC stricter. In GCC 8.2, int foo(void) { return ({3;}); }
compiles without complaint using just -Wall -std=c11
but gets this warning with -pedantic
added:
warning: ISO C forbids braced-groups within expressions [-Wpedantic]
(The feature used, statement expressions, is intended for use in macros. It is used in my example solely as proof-of-principle.)
Comparing and contrasting:
-std=gnu11
, for example, requests a non-standard version of C.-std=c11
requests a standard version of C. The C standard permits, and even invites, extensions, so you may still use certain GNU extensions with -std=c11
.-pedantic
requests the compiler warn about certain GNU extensions and “traditional” features that it otherwise permits.The documentation also suggests GCC may be lax about certain warnings it should issue with standard C, and -pedantic
causes it to issue all warnings required by strict ISO C.
There may be additional variations; I am not an expert on GCC dialects and switches.