From 637226230419548847d7fa09e2bf996966d4b224 Mon Sep 17 00:00:00 2001 From: rexy712 Date: Thu, 30 Jun 2022 12:14:46 -0700 Subject: [PATCH] Fix msvc warnings --- CMakeLists.txt | 5 +++-- include/rexy/cx/string.hpp | 2 +- src/filerd.cpp | 5 +++++ tests/CMakeLists.txt | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a224e0..d8696e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,8 @@ else() endif() if(MSVC) - target_compile_options(rexy PRIVATE "/Zc:__cplusplus" "/Wall") + #make msvc update the __cplusplus macro to actually comply to c++ standard + target_compile_options(rexy PRIVATE "/Zc:__cplusplus") else() target_compile_options(rexy PRIVATE "-Wall" "-Wextra" "-pedantic") endif() @@ -70,7 +71,7 @@ endif() if(BUILD_TESTS) add_library(ensure OBJECT "src/ensure.cpp") if(MSVC) - target_compile_options(ensure PRIVATE "/Zc:__cplusplus" "/Wall") + target_compile_options(ensure PRIVATE "/Zc:__cplusplus") else() target_compile_options(ensure PRIVATE "-Wall" "-Wextra" "-pedantic") endif() diff --git a/include/rexy/cx/string.hpp b/include/rexy/cx/string.hpp index d5aa7a4..f26e22b 100644 --- a/include/rexy/cx/string.hpp +++ b/include/rexy/cx/string.hpp @@ -60,7 +60,7 @@ namespace rexy::cx{ public: static constexpr size_type max_size = N; - static constexpr size_type npos = size_type{-1}; + static constexpr size_type npos = size_type(-1); public: value_type m_data[N] = {}; diff --git a/src/filerd.cpp b/src/filerd.cpp index 82834df..b66b5eb 100644 --- a/src/filerd.cpp +++ b/src/filerd.cpp @@ -16,6 +16,11 @@ along with this program. If not, see . */ +#ifdef _MSC_VER + //Disable warning from msvc for not using fopen_s + //which is not standard in c++ as of c++23, though it is in c since c11. + #define _CRT_SECURE_NO_WARNINGS +#endif #include "rexy/filerd.hpp" #include //fopen, fclose diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0ee0803..a0015e9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,7 +6,7 @@ include_directories("${INCLUDE_PATH}") set(CMAKE_CXX_STANDARD 20) if(MSVC) - add_compile_options("/Zc:__cplusplus" "/Wall") + add_compile_options("/Zc:__cplusplus") else() add_compile_options("-Wall" "-Wextra" "-pedantic") endif()