Fix msvc warnings

This commit is contained in:
rexy712 2022-06-30 12:14:46 -07:00
parent 7ee0beb343
commit 6372262304
4 changed files with 10 additions and 4 deletions

View File

@ -49,7 +49,8 @@ else()
endif() endif()
if(MSVC) 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() else()
target_compile_options(rexy PRIVATE "-Wall" "-Wextra" "-pedantic") target_compile_options(rexy PRIVATE "-Wall" "-Wextra" "-pedantic")
endif() endif()
@ -70,7 +71,7 @@ endif()
if(BUILD_TESTS) if(BUILD_TESTS)
add_library(ensure OBJECT "src/ensure.cpp") add_library(ensure OBJECT "src/ensure.cpp")
if(MSVC) if(MSVC)
target_compile_options(ensure PRIVATE "/Zc:__cplusplus" "/Wall") target_compile_options(ensure PRIVATE "/Zc:__cplusplus")
else() else()
target_compile_options(ensure PRIVATE "-Wall" "-Wextra" "-pedantic") target_compile_options(ensure PRIVATE "-Wall" "-Wextra" "-pedantic")
endif() endif()

View File

@ -60,7 +60,7 @@ namespace rexy::cx{
public: public:
static constexpr size_type max_size = N; static constexpr size_type max_size = N;
static constexpr size_type npos = size_type{-1}; static constexpr size_type npos = size_type(-1);
public: public:
value_type m_data[N] = {}; value_type m_data[N] = {};

View File

@ -16,6 +16,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#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 "rexy/filerd.hpp"
#include <cstdio> //fopen, fclose #include <cstdio> //fopen, fclose

View File

@ -6,7 +6,7 @@ include_directories("${INCLUDE_PATH}")
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
if(MSVC) if(MSVC)
add_compile_options("/Zc:__cplusplus" "/Wall") add_compile_options("/Zc:__cplusplus")
else() else()
add_compile_options("-Wall" "-Wextra" "-pedantic") add_compile_options("-Wall" "-Wextra" "-pedantic")
endif() endif()