views:

107

answers:

1

I'm learning my way around visual studio at the moment. If I've turned set /Wall -- I'll be greeted with a seemingly unhealthy amount of warning messages although my application will compile just fine.

Is this normal? Changing the error level will stop the messages. It looks as if they are all related to the C++ STL or its header files - same thing?

If I build the program using code::blocks (GCC) then no errors are reported despite the same warning level.

What's going on here?

update: visual studio /Wall output: http://pastebin.com/FBGLd2Hb visual studio /W4 output: http://pastebin.com/YuWKVS9G

The code is actually from Wrox Professional C++. I could be wrong about my usage of the word warnings?

+4  A: 

With g++ -Wall does not turn on all warnings, just a practical subset. I suspect that with MSVC /Wall turns on more warnings than is practical. MSVC is very enthusiastic about warnings.

With MSVC use /W4 for high warning level.

You'll have to turn off MSVC sillywarnings; you can use my anti-MSVC-sillywarnings header for that.

Cheers & hth.,

Alf P. Steinbach
No offense, but disabling a bunch of warnings without knowing exactly what they warn you about seems very **wrong**. Some warnings might indeed be spurious, but most of the time they indicate a real problem.
ereOn
Alf P. Steinbach
/W4 does stop almost everything. What's left seems directly to the code, which I understand.
aLostMonkey
Well, at the time of this comment, I hadn't seen the warnings yet. Indeed, in this case, most of them seem spurious. But I still got the feeling that this should be fixed by the compiler vendor, not by some community-created header file.
ereOn
@Alf P. Steinbach: "disable:4099", "first seen using 'struct' now seen using 'class'" --> this is a real concern, C++ does not mandate that both resolve to the same entity which effectively authorize compilers to emit different (mangled) names. I seem to recall that MSVC did it, perhaps it doesn't any longer. Anyway this one is easily fixed. Explicitly handling all enum values is also a good thing (at the very least, for documentation). I think you may have been a bit too enthusiastic too :)
Matthieu M.
reproduced using an incredibly simple program. I guess I have nothing to worry about, I'll stick to /W4.
aLostMonkey
@Mattieu: re 4099, it's a judgment call. You can read my thinking about it, with some examples, [here](http://alfps.wordpress.com/2010/06/22/cppx-is-c4099-really-a-sillywarning-disabling-msvc-sillywarnings/), which -- heh -- links back to StackOverflow... Perhaps in some shops it's better turned on. Re the enum values in a `switch`, as I recall it's a warning emitted even when you have a `default`, so, very high nuisance factor. Cheers,
Alf P. Steinbach
+1, for your antimscv.
Green Code
@ereOn: now you just need to convince Microsoft of that... Until then, the best we can do is disable the warnings ourselves. ;)
jalf
@jalf: Almost done. I'm dining with Steve Ballmer tonight. Keeping you posted :)
ereOn
Regarding the "sillywarnings", some have even errors in the MSDN references. E.g http://msdn.microsoft.com/en-us/library/2cf74y2b.aspx explains that you get a warning because this class can't be instantiated (so why not give an error if I tried!?), but the *struct* in the example **can** be instantiated as an aggregate - even with VC++ :)
UncleBens