Skip to content

Commit 025ebb2

Browse files
committed
CXX-638 Fixes required for VS2015 support
1 parent 3c3f8f2 commit 025ebb2

26 files changed

+169
-58
lines changed

src/bsoncxx/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ install(FILES
131131

132132
install(TARGETS
133133
bsoncxx
134+
RUNTIME DESTINATION bin COMPONENT runtime
134135
LIBRARY DESTINATION lib COMPONENT runtime
135136
ARCHIVE DESTINATION lib COMPONENT dev
136137
)

src/bsoncxx/builder/concatenate.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ namespace builder {
2727
/// Container to concatenate a document. Use it by constructing an instance with the
2828
/// document to be concatenated, and pass it into a document stream builder.
2929
///
30-
struct BSONCXX_API concatenate_doc {
30+
struct concatenate_doc {
3131
document::view_or_value doc;
3232

33+
// MSVC seems to need a hint that it should always
34+
// inline this destructor;
35+
BSONCXX_INLINE ~concatenate_doc() = default;
36+
3337
BSONCXX_INLINE operator document::view() const {
3438
return doc;
3539
}
@@ -43,9 +47,13 @@ struct BSONCXX_API concatenate_doc {
4347
/// Container to concatenate an array. Use this with the array stream builder in order
4448
/// to pass an array into a new builder and append its values to the stream.
4549
///
46-
struct BSONCXX_API concatenate_array {
50+
struct concatenate_array {
4751
array::view_or_value array;
4852

53+
// MSVC seems to need a hint that it should always
54+
// inline this destructor;
55+
BSONCXX_INLINE ~concatenate_array() = default;
56+
4957
BSONCXX_INLINE operator array::view() const {
5058
return array;
5159
}

src/bsoncxx/builder/stream/array_context.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ class array_context {
6767
BSONCXX_INLINE typename std::enable_if<
6868
std::is_same<base, closed_context>::value &&
6969
std::is_same<typename std::remove_reference<T>::type, const finalize_type>::value,
70-
array::value>::type
70+
// TODO(MSVC): This should just be 'array::value', but
71+
// VS2015U1 can't resolve the name.
72+
bsoncxx::array::value>::type
7173
operator<<(T&&) {
7274
return _core->extract_array();
7375
}

src/bsoncxx/builder/stream/key_context.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ class key_context {
6464
BSONCXX_INLINE typename std::enable_if<
6565
std::is_same<base, closed_context>::value &&
6666
std::is_same<typename std::remove_reference<T>::type, const finalize_type>::value,
67-
document::value>::type
67+
// TODO(MSVC): This should just be 'document::value', but
68+
// VS2015U1 can't resolve the name.
69+
bsoncxx::document::value>::type
6870
operator<<(T&&) {
6971
return _core->extract_document();
7072
}

src/bsoncxx/builder/stream/value_context.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ class value_context {
6060

6161
operator single_context();
6262

63+
#if !defined(_MSC_VER)
64+
// TODO(MSVC): Causes an ICE under VS2015U1
6365
static_assert(std::is_same<value_context, decltype(std::declval<value_context>() << 1 << "str")>::value,
6466
"value_context must be templatized on a key_context");
67+
#endif
6568

6669
private:
6770
BSONCXX_INLINE base unwrap() { return base(_core); }

src/bsoncxx/config/compiler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#pragma warning(push)
2020
#pragma warning(disable: 4251)
2121

22-
#define BSONCXX_INLINE inline __forceinline
22+
#define BSONCXX_INLINE inline __forceinline BSONCXX_PRIVATE
2323

2424
#else
25-
#define BSONCXX_INLINE inline __attribute__((__visibility__("hidden"), __always_inline__))
25+
#define BSONCXX_INLINE inline __attribute__((__always_inline__)) BSONCXX_PRIVATE
2626
#endif

src/bsoncxx/config/postlude.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,20 @@ static_assert(false, "BSONCXX_ENUM must be undef'ed");
5656
// export.hpp (generated by cmake)
5757
#undef BSONCXX_API_H
5858
#pragma pop_macro("BSONCXX_API_H")
59+
#undef BSONCXX_API
60+
#pragma pop_macro("BSONCXX_API")
61+
#undef BSONCXX_PRIVATE
62+
#pragma pop_macro("BSONCXX_PRIVATE")
5963
#undef BSONCXX_DEPRECATED
6064
#pragma pop_macro("BSONCXX_DEPRECATED")
6165
#undef BSONCXX_DEPRECATED_EXPORT
6266
#pragma pop_macro("BSONCXX_DEPRECATED_EXPORT")
6367
#undef BSONCXX_DEPRECATED_NO_EXPORT
6468
#pragma pop_macro("BSONCXX_DEPRECATED_NO_EXPORT")
69+
#undef DEFINE_NO_DEPRECATED
70+
#pragma pop_macro("DEFINE_NO_DEPRECATED")
6571
#undef BSONCXX_NO_DEPRECATED
6672
#pragma pop_macro("BSONCXX_NO_DEPRECATED")
67-
#undef BSONCXX_PRIVATE
68-
#pragma pop_macro("BSONCXX_PRIVATE")
69-
#undef BSONCXX_API
70-
#pragma pop_macro("BSONCXX_API")
7173

7274
// prelude.hpp
7375
#undef BSONCXX_UNREACHABLE

src/bsoncxx/config/prelude.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,25 @@
5151
// export.hpp (generated by cmake)
5252
#pragma push_macro("BSONCXX_API_H")
5353
#undef BSONCXX_API_H
54+
#pragma push_macro("BSONCXX_API")
55+
#undef BSONCXX_API
56+
#pragma push_macro("BSONCXX_PRIVATE")
57+
#undef BSONCXX_PRIVATE
5458
#pragma push_macro("BSONCXX_DEPRECATED")
5559
#undef BSONCXX_DEPRECATED
5660
#pragma push_macro("BSONCXX_DEPRECATED_EXPORT")
5761
#undef BSONCXX_DEPRECATED_EXPORT
5862
#pragma push_macro("BSONCXX_DEPRECATED_NO_EXPORT")
5963
#undef BSONCXX_DEPRECATED_NO_EXPORT
64+
#pragma push_macro("DEFINE_NO_DEPRECATED")
65+
#undef DEFINE_NO_DEPRECATED
6066
#pragma push_macro("BSONCXX_NO_DEPRECATED")
6167
#undef BSONCXX_NO_DEPRECATED
62-
#pragma push_macro("BSONCXX_PRIVATE")
63-
#undef BSONCXX_PRIVATE
64-
#pragma push_macro("BSONCXX_API")
65-
#undef BSONCXX_API
6668

67-
#include <bsoncxx/config/compiler.hpp>
6869
#include <bsoncxx/config/config.hpp>
6970
#include <bsoncxx/config/version.hpp>
7071
#include <bsoncxx/config/export.hpp>
72+
#include <bsoncxx/config/compiler.hpp>
7173

7274
#pragma push_macro("BSONCXX_UNREACHABLE")
7375
#undef BSONCXX_UNREACHABLE

src/bsoncxx/oid.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
namespace bsoncxx {
2525
BSONCXX_INLINE_NAMESPACE_BEGIN
2626

27+
const oid::init_tag_t oid::init_tag{};
28+
2729
oid::oid() : _is_valid(false) {
2830
}
2931

src/bsoncxx/oid.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ BSONCXX_INLINE_NAMESPACE_BEGIN
3838
class BSONCXX_API oid {
3939
public:
4040
struct init_tag_t {};
41-
static constexpr init_tag_t init_tag{};
41+
42+
// TODO(MSVC): Ideally this would be constexpr, but VS2015U1 can't
43+
// handle it.
44+
//
45+
// See https://connect.microsoft.com/VisualStudio/feedback/details/2092790
46+
//
47+
static const init_tag_t init_tag;
4248

4349
///
4450
/// Constructs an uninitialized oid.

0 commit comments

Comments
 (0)