kastnermario / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

alarming warning when compiling with visual studio 2008 #64

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
when building the library with the supplied project file for visual studio
2008 it produces warnings like:

warning C4913: user defined binary operator ',' exists but no overload
could convert all operands, default built-in binary operator ',' used...

a user defined , operator really exists, and if the compiler ignores it,
that could create a bug, which should be fixed.

i must admit that i don't understand the code / templates trick revolving
around fallback::flag, but the warning seems to indicate that it doesn't work.

alternatively if these (and other) warnings are acceptable, maybe they
should be disabled via the project file, or #pragma.

Original issue reported on code.google.com by oranagra...@gmail.com on 23 Feb 2010 at 7:13

GoogleCodeExporter commented 8 years ago
That bit of black magic relies on overloading the comma operator but sometimes 
falling back to the default one. 
Visual Studio compiles it properly, but I suppose is worried for us :)

Is there a way to selectively disable that warning just for this stretch of 
code?

Original comment by jbe...@gmail.com on 23 Feb 2010 at 7:33

GoogleCodeExporter commented 8 years ago
sure, this can be done either at the project level (in the .vcproj file), or in 
the
source code using "#pragma warning (disable: 4127 4913 4996 4355)"

the warnings i see in visual studio are:
warning C4127: conditional expression is constant
warning C4913: user defined binary operator ',' exists but no...
warning C4996: 'std::basic_streambuf<_Elem,_Traits>::sgetn': Function call with
parameters that may be unsafe - this call relies on the caller to check that the
passed values are correct. To disable this warning, use 
-D_SCL_SECURE_NO_WARNINGS.
warning C4355: 'this' : used in base member initializer list

the attached file contains the output of the compiler so you can see in what 
lines
each warning occur and maybe resolve some of them by changing the code rather 
than
suppressing the warnings.

disabling them through the project file is done at: project properties > C/C++ >
advanced > disable specific warnings.
set it to 4127;4913;4996;4355 for both debug and release configurations.

or add the following line to the .vcproj file under <Tool 
Name="VCCLCompilerTool"
DisableSpecificWarnings="4127;4913;4996;4355"
for both debug and release.

Original comment by oranagra...@gmail.com on 23 Feb 2010 at 8:47

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks, fixed (r351). I didn't disable all the warnings, just the ones that 
appeared 
particularly annoying. I also "fixed" one of them.

Original comment by jbe...@gmail.com on 3 Mar 2010 at 5:33