Skip to content

Commit e6f82cf

Browse files
committed
Fixed #463.
Added lacked include files. Added a test. Added MSVC build settings on appveyor. Added old MSVC workaround. Fixed a variable definition point to meet ANSI-C.
1 parent 068041f commit e6f82cf

File tree

12 files changed

+82
-33
lines changed

12 files changed

+82
-33
lines changed

appveyor.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
11
version: 1.1.0.{build}
2-
before_build:
2+
3+
environment:
4+
matrix:
5+
- cpp11: -DMSGPACK_CXX11=OFF
6+
boost: -DMSGPACK_BOOST=ON
7+
msvc: '"Visual Studio 10 2010"'
8+
- cpp11: -DMSGPACK_CXX11=OFF
9+
boost: -DMSGPACK_BOOST=ON
10+
msvc: '"Visual Studio 11 2012"'
11+
- cpp11: -DMSGPACK_CXX11=OFF
12+
boost: -DMSGPACK_BOOST=ON
13+
msvc: '"Visual Studio 12 2013"'
14+
- cpp11: -DMSGPACK_CXX11=ON
15+
boost: -DMSGPACK_BOOST=ON
16+
msvc: '"Visual Studio 14 2015"'
17+
- cpp11: -DMSGPACK_CXX11=OFF
18+
boost: -DMSGPACK_BOOST=ON
19+
msvc: '"Visual Studio 14 2015"'
20+
- cpp11: -DMSGPACK_CXX11=ON
21+
boost: -DMSGPACK_BOOST=OFF
22+
msvc: '"Visual Studio 14 2015"'
23+
- cpp11: -DMSGPACK_CXX11=OFF
24+
boost: -DMSGPACK_BOOST=OFF
25+
msvc: '"Visual Studio 14 2015"'
26+
build_script:
327
- appveyor DownloadFile http://googletest.googlecode.com/files/gtest-1.7.0.zip -FileName gtest-1.7.0.zip
428
- 7z x gtest-1.7.0.zip > NUL
529
- cd gtest-1.7.0
630
- md build
731
- cd build
8-
- cmake -DBUILD_SHARED_LIBS=ON ..
32+
- cmake -G %msvc% -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS=/D_VARIADIC_MAX=10 ..
933
- cmake --build . --config Release
1034
- cd ..
1135
- cd ..
@@ -15,26 +39,14 @@ before_build:
1539
- cd zlib-1.2.8
1640
- md build
1741
- cd build
18-
- cmake ..
42+
- cmake -G %msvc% ..
1943
- cmake --build . --config Release
2044
- copy zconf.h ..
2145
- cd ..
2246
- cd ..
23-
24-
environment:
25-
matrix:
26-
- cpp11: -DMSGPACK_CXX11=ON
27-
boost: -DMSGPACK_BOOST=ON
28-
- cpp11: -DMSGPACK_CXX11=OFF
29-
boost: -DMSGPACK_BOOST=ON
30-
- cpp11: -DMSGPACK_CXX11=ON
31-
boost: -DMSGPACK_BOOST=OFF
32-
- cpp11: -DMSGPACK_CXX11=OFF
33-
boost: -DMSGPACK_BOOST=OFF
34-
build_script:
3547
- md build
3648
- cd build
37-
- cmake %cpp11% %boost% -DMSGPACK_BOOST_DIR=C:\Libraries\\boost_1_58_0 -DGTEST_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest.lib -DGTEST_MAIN_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest_main.lib -DGTEST_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\include -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8\build\Release\zlib.lib -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8 ..
49+
- cmake -G %msvc% %cpp11% %boost% -DMSGPACK_BOOST_DIR=C:\Libraries\\boost_1_60_0 -DGTEST_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest.lib -DGTEST_MAIN_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest_main.lib -DGTEST_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\include -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8\build\Release\zlib.lib -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8 -DCMAKE_CXX_FLAGS='"/D_VARIADIC_MAX=10 /EHsc"' ..
3850
- cmake --build . --config Release
3951

4052
test_script:

erb/v1/cpp03_define_map.hpp.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "msgpack/adaptor/adaptor_base.hpp"
1616
#include "msgpack/object_fwd.hpp"
1717

18+
#include <map>
19+
1820
namespace msgpack {
1921
/// @cond
2022
MSGPACK_API_VERSION_NAMESPACE(v1) {

example/c/lib_buffer_unpack.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ size_t receiver_recv(receiver *r, char* buf, size_t try_size) {
4444
size_t receiver_to_unpacker(receiver* r, size_t request_size,
4545
msgpack_unpacker *unpacker)
4646
{
47+
size_t recv_len;
4748
// make sure there's enough room, or expand the unpacker accordingly
4849
if (msgpack_unpacker_buffer_capacity(unpacker) < request_size) {
4950
msgpack_unpacker_reserve_buffer(unpacker, request_size);
5051
assert(msgpack_unpacker_buffer_capacity(unpacker) >= request_size);
5152
}
52-
size_t recv_len = receiver_recv(r, msgpack_unpacker_buffer(unpacker),
53-
request_size);
53+
recv_len = receiver_recv(r, msgpack_unpacker_buffer(unpacker),
54+
request_size);
5455
msgpack_unpacker_buffer_consumed(unpacker, recv_len);
5556
return recv_len;
5657
}

include/msgpack/v1/adaptor/adaptor_base_decl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "msgpack/versioning.hpp"
1414
#include "msgpack/object_fwd.hpp"
15+
#include "msgpack/pack.hpp"
1516

1617
namespace msgpack {
1718

include/msgpack/v1/adaptor/boost/msgpack_variant.hpp

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ struct basic_variant :
8282
basic_variant() {}
8383
template <typename T>
8484
basic_variant(T const& t):base(t) {}
85+
86+
#if defined(_MSC_VER) && _MSC_VER < 1700
87+
// The following redundant functions are required to avoid MSVC
88+
// See https://svn.boost.org/trac/boost/ticket/592
89+
basic_variant(basic_variant const& other):base(static_cast<base const&>(other)) {}
90+
basic_variant& operator=(basic_variant const& other) {
91+
*static_cast<base*>(this) = static_cast<base const&>(other);
92+
return *this;
93+
}
94+
#endif // defined(_MSC_VER) && _MSC_VER < 1700
95+
8596
basic_variant(char const* p):base(std::string(p)) {}
8697
basic_variant(char v) {
8798
int_init(v);
@@ -104,51 +115,51 @@ struct basic_variant :
104115
basic_variant(unsigned long long v):base(uint64_t(v)) {}
105116

106117
bool is_nil() const {
107-
return boost::get<msgpack::type::nil_t>(this);
118+
return boost::get<msgpack::type::nil_t>(this) != nullptr;
108119
}
109120
bool is_bool() const {
110-
return boost::get<bool>(this);
121+
return boost::get<bool>(this) != nullptr;
111122
}
112123
bool is_int64_t() const {
113-
return boost::get<int64_t>(this);
124+
return boost::get<int64_t>(this) != nullptr;
114125
}
115126
bool is_uint64_t() const {
116-
return boost::get<uint64_t>(this);
127+
return boost::get<uint64_t>(this) != nullptr;
117128
}
118129
bool is_double() const {
119-
return boost::get<double>(this);
130+
return boost::get<double>(this) != nullptr;
120131
}
121132
bool is_string() const {
122-
return boost::get<std::string>(this);
133+
return boost::get<std::string>(this) != nullptr;
123134
}
124135
#if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53
125136
bool is_boost_string_ref() const {
126-
return boost::get<boost::string_ref>(this);
137+
return boost::get<boost::string_ref>(this) != nullptr;
127138
}
128139
#endif // (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53
129140
bool is_vector_char() const {
130-
return boost::get<std::vector<char> >(this);
141+
return boost::get<std::vector<char> >(this) != nullptr;
131142
}
132143
bool is_vector_char() {
133-
return boost::get<std::vector<char> >(this);
144+
return boost::get<std::vector<char> >(this) != nullptr;
134145
}
135146
bool is_raw_ref() const {
136-
return boost::get<raw_ref>(this);
147+
return boost::get<raw_ref>(this) != nullptr;
137148
}
138149
bool is_ext() const {
139-
return boost::get<ext>(this);
150+
return boost::get<ext>(this) != nullptr;
140151
}
141152
bool is_ext_ref() const {
142-
return boost::get<ext_ref>(this);
153+
return boost::get<ext_ref>(this) != nullptr;
143154
}
144155
bool is_vector() const {
145-
return boost::get<std::vector<basic_variant<STR, BIN, EXT> > >(this);
156+
return boost::get<std::vector<basic_variant<STR, BIN, EXT> > >(this) != nullptr;
146157
}
147158
bool is_map() const {
148-
return boost::get<std::map<basic_variant<STR, BIN, EXT>, basic_variant<STR, BIN, EXT> > >(this);
159+
return boost::get<std::map<basic_variant<STR, BIN, EXT>, basic_variant<STR, BIN, EXT> > >(this) != nullptr;
149160
}
150161
bool is_multimap() const {
151-
return boost::get<std::multimap<basic_variant<STR, BIN, EXT>, basic_variant<STR, BIN, EXT> > >(this);
162+
return boost::get<std::multimap<basic_variant<STR, BIN, EXT>, basic_variant<STR, BIN, EXT> > >(this) != nullptr;
152163
}
153164

154165
bool as_bool() const {

include/msgpack/v1/adaptor/detail/cpp03_define_map.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "msgpack/adaptor/adaptor_base.hpp"
1616
#include "msgpack/object_fwd.hpp"
1717

18+
#include <map>
19+
1820
namespace msgpack {
1921
/// @cond
2022
MSGPACK_API_VERSION_NAMESPACE(v1) {

include/msgpack/v1/adaptor/int.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#define MSGPACK_V1_TYPE_INT_HPP
1212

1313
#include "msgpack/v1/adaptor/int_decl.hpp"
14+
#include "msgpack/object.hpp"
15+
1416
#include <limits>
1517

1618
namespace msgpack {

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ LIST (APPEND check_PROGRAMS
1414
convert.cpp
1515
fixint.cpp
1616
fixint_c.cpp
17+
inc_adaptor_define.cpp
1718
json.cpp
1819
limit.cpp
1920
msgpack_basic.cpp

test/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ check_PROGRAMS = \
99
convert \
1010
fixint \
1111
fixint_c \
12+
inc_adaptor_define \
1213
json \
1314
limit \
1415
msgpack_basic \
@@ -54,6 +55,7 @@ cases_SOURCES = cases.cpp
5455
convert_SOURCES = convert.cpp
5556
fixint_SOURCES = fixint.cpp
5657
fixint_c_SOURCES = fixint_c.cpp
58+
inc_adaptor_define_SOURCES = inc_adaptor_define.cpp
5759
json_SOURCES = json.cpp
5860
limit_SOURCES = limit.cpp
5961
msgpack_basic_SOURCES = msgpack_basic.cpp

test/inc_adaptor_define.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include <msgpack/adaptor/define.hpp>
2+
3+
int main() {}

0 commit comments

Comments
 (0)