I want to be warned about everything possible using the GCC compiler. Is there a way to get the same behaviour as Clang's -Weverything when using GCC?
1 Answers
From the LLVM Clang Documentation:
Enabling All Diagnostics In addition to the traditional -W flags, one can enable all diagnostics by passing -Weverything. This works as expected with -Werror, and also includes the warnings from -pedantic. Some diagnostics contradict each other, therefore, users of -Weverything often disable many diagnostics such as -Wno-c++98-compat and -Wno-c++-compat because they contradict recent C++ standards.
Since -Weverything enables every diagnostic, we generally don’t recommend using it. -Wall -Wextra are a better choice for most projects. Using -Weverything means that updating your compiler is more difficult because you’re exposed to experimental diagnostics which might be of lower quality than the default ones. If you do use -Weverything then we advise that you address all new compiler diagnostics as they get added to Clang, either by fixing everything they find or explicitly disabling that diagnostic with its corresponding Wno- option.
Note that when combined with -w (which disables all warnings), disabling all warnings wins.
From the definition of gcc's documentation regarding -Wall argument:
This enables 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. This also enables some language-specific warnings described in C++ Dialect Options and Objective-C and Objective-C++ Dialect Options.
Please refer to gcc's documentation which flags enabled by -Wall
As a result, it would be frustrating to use the -Weverything with clang because all details will be listed and enabled some experimental warning messages, as mentioned in the quote.

- 81
- 8
-
2"-Wall enables all compiler's warning messages" - unfortunately that's incorrect. There're at least `-Wextra` and `-Wconversion`. – yugr Jan 01 '22 at 19:30
-
1There is `-Wextra`, `-Wnon-gcc`, and many others that aren't enabled. I have a whole list of them. https://gist.github.com/GavinRay97/bae1d93925e55ce0a0084946f24984cf – Gavin Ray Jan 14 '23 at 23:37