diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b90333..a7a21f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,14 @@ endif() # Specific flags for Visual C++ if(MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -TC") + # Treat all files a C source files + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TC") + # Set warning level to /W4 + string(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) + # Enable /Zc:strictStrings when msvc_ver > 2012 and build_type != Debug + if((MSVC_VERSION GREATER 1700) AND NOT (CMAKE_BUILD_TYPE STREQUAL "Debug")) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Zc:strictStrings") + endif() add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() diff --git a/tests/test_platform.c b/tests/test_platform.c index 5401e9d..39cc30a 100644 --- a/tests/test_platform.c +++ b/tests/test_platform.c @@ -22,6 +22,11 @@ #include +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4127) /* "conditional expression is constant" */ +#endif + const char* test_platform__alignment() { UTEST_ASSERT(offsetof(gmio_stl_coords_t, x) == 0); @@ -56,6 +61,10 @@ const char* test_platform__global_h() return NULL; } +#ifdef _MSC_VER +# pragma warning(pop) +#endif + const char* all_tests() { UTEST_SUITE_START(); diff --git a/tests/utest_lib.h b/tests/utest_lib.h index 1e6fee0..721ee15 100644 --- a/tests/utest_lib.h +++ b/tests/utest_lib.h @@ -25,6 +25,7 @@ #define UTEST_MAIN(name) \ int main(int argc, char *argv[]) {\ + (void)argc; \ const char *result = NULL; \ \ printf("----\nRUNNING: %s\n", argv[0]);\