gcc compiler options according to visual studio warning level /W3

Jonathan Wakely jwakely.gcc@gmail.com
Mon Mar 29 12:38:56 GMT 2021

On Mon, 29 Mar 2021 at 13:18, Markus Forrer via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
> I have a project that I am building with both Visual Studio and gcc. Now I am looking for the gcc compiler options to get the same warnings as with Visual Studio warning level /W3.

I have no idea what set of warnings /W3 enables, but the warnings that
are emitted by different compilers vary, and how trigger happy those
warnings are varies. You will never get "the same warnings" from two
different compilers.

You probably want the -Wall option:

"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.
Note that some warning flags are not implied by -Wall.  Some of them
warn about constructions that users generally do not consider
questionable, but which occasionally you might wish to check for;
others warn about constructions that are necessary or hard to avoid in
some cases, and there is no simple way to modify the code to suppress
the warning. Some of them are enabled by -Wextra but many of them must
be enabled individually."

You might want to try -Wextra to enable those additional warnings
(that might be roughly similar to /W4).

More information about the Gcc-help mailing list