I ran into this while compiling some portable code in gcc
. Basically this strange code compiles in Visual studio which really just blows my mind:
As others said, this is due to Microsoft C++ extension. Though /Za
flag is not recommended as it can break things.
Instead use the /permissive-
switch for better standards compliancy and you will get healthy errors for these cases. Note that this flag is available since VS 2017.
The switch /Za does not support certain key Microsoft SDK header files. By contrast /permissive- offers a useful conformance mode where input C++ code is interpreted according to ISO C++ rules but also allows conforming extensions necessary to compile C++ on targets supported by Visual C++.
More info is on Visual C++ Team Blog.