In the same direction as described in the conversion to 'size_t from' int, you can change the sign of the result - GCC, C , instead I would like to ensure that the warning that I get in GCC 4.2.1 is also marked under VS2008 SP1 in both 32-bit and 64-bit compilation compared to disabling alerts in GCC in accordance with VS2008.
For example, in accordance with GCC 4.2.1 in 64-bit conditions, we see the following as a warning in -Wall conditions:
#include <string.h> bool foo() { size_t len = 0; const char * someBuffer = "flubber"; len = strlen(someBuffer); bool retval = false; for (int j = 0; j < len; j++) // <-- warning { if (someBuffer[j] != '0') { retval = true; break; } } return retval; }
GCC Warning:
warning: comparison between signed and unsigned integer expressions
But it is not tagged with the 64-bit VS2008 SP1 compiler, no matter what types of pragmas I try, and no matter what I allow to use / W 3 or / W4, or / w 3 some_warning_number or / w 4 some_warning_number , etc. d.
Now I donβt want to lower the GCC warning levels or turn off the warning, as they have a warning there for very good reasons. Therefore, I would like VS builds to fail in the same way when / WX is enabled. Should I live with this, or is there some kind of warning that could do the trick on VS2008?
EDIT: A warning appears for 32-bit builds, but does not use 64-bit builds, using the same set of compiler options, as shown below:
/O2 /Ob2 /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "_CRT_SECURE_NO_WARNINGS" /D "__WIN32__" /D "_SCL_SECURE_NO_WARNINGS" /D "_BIND_TO_CURRENT_MFC_VERSION" /D "_BIND_TO_CURRENT_CRT_VERSION" /D "WINVER=0x0502" /D "_WIN32_WINNT=0x0502" /D "_WIN32" /D "_NT" /D "_CRT_NONSTDC_NO_WARNINGS" /D "_MBCS" /FD /EHsc /MD /W3 /WX /TP /Zm1000
EDIT # 1: Seeing that it could be Visual Studio idiosyncrasy, I sent Visual C ++ Development Center warning C4018: '<': signed / unsigned mismatch was selected for 32-bit but not 64-bit compilation in VS2008 SP1 on 64-bit Windows .
EDIT # 2: I was sent a message to Microsoft Connect from the Visual C ++ Developer Center and today (2011-01-11) Microsoft answered my question and checked it as a problem with the compiler: they stated that the problem would add to the lag, which will be fixed in the next version: Microsoft Connect - warning C4018: '<': signature / unsigned mismatch is emitted only between size type types .