Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Visual Studio 2017 warnings #788

Merged
merged 2 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5292,7 +5292,7 @@ class binary_reader
{
get();
check_eof();
return current;
return static_cast<char>(current);
});
return result;
}
Expand Down
5 changes: 4 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ if(MSVC)
endif()

# Disable warning C4389: '==': signed/unsigned mismatch
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4389")
# Disable warning C4309: 'static_cast': truncation of constant value
# Disable warning C4566: character represented by universal-character-name '\uFF01' cannot be represented in the current code page (1252)
# Disable warning C4996: 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::operator <<': was declared deprecated
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4389 /wd4309 /wd4566 /wd4996")
endif()

#############################################################################
Expand Down
2 changes: 1 addition & 1 deletion test/src/unit-constructor1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ TEST_CASE("constructors")

SECTION("std::pair")
{
std::pair<float, std::string> p{1.0, "string"};
std::pair<float, std::string> p{1.0f, "string"};
json j(p);

CHECK(j.type() == json::value_t::array);
Expand Down
9 changes: 9 additions & 0 deletions test/src/unit-readme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ using nlohmann::json;
#include <unordered_set>
#include <iostream>

#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning (disable : 4189) // local variable is initialized but not referenced
#endif

TEST_CASE("README", "[hide]")
{
{
Expand Down Expand Up @@ -298,3 +303,7 @@ TEST_CASE("README", "[hide]")
std::cout.rdbuf(old_cout_buffer);
}
}

#if defined(_MSC_VER)
#pragma warning (pop)
#endif