Skip to content

Commit a70c9b1

Browse files
committed
Disable C4251 and C4275 warnings for exception classes
1 parent 960873f commit a70c9b1

File tree

8 files changed

+30
-21
lines changed

8 files changed

+30
-21
lines changed

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/compiler.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@
3636

3737
// clang-format on
3838

39-
// Disable MSVC warnings that cause a lot of noise related to DLL visibility
40-
// for types that we don't control (like std::unique_ptr).
41-
BSONCXX_PUSH_WARNINGS();
42-
BSONCXX_DISABLE_WARNING(MSVC(4251));
43-
BSONCXX_DISABLE_WARNING(MSVC(5275));
44-
4539
// For backward compatibility. Use `inline` instead.
4640
#define BSONCXX_INLINE inline BSONCXX_ABI_NO_EXPORT
4741

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
// compiler.hpp
1616
#undef BSONCXX_INLINE
1717
#pragma pop_macro("BSONCXX_INLINE")
18-
BSONCXX_POP_WARNINGS();
1918
#undef BSONCXX_CALL
2019
#pragma pop_macro("BSONCXX_CALL")
2120

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/exception.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
namespace bsoncxx {
2424
namespace v_noabi {
2525

26+
BSONCXX_PUSH_WARNINGS();
27+
BSONCXX_DISABLE_WARNING(MSVC(4251));
28+
BSONCXX_DISABLE_WARNING(MSVC(4275));
29+
2630
///
2731
/// Class representing any exceptions emitted from the bsoncxx library or
2832
/// its underlying implementation.
@@ -39,6 +43,8 @@ class exception : public std::system_error {
3943
using std::system_error::system_error;
4044
};
4145

46+
BSONCXX_POP_WARNINGS();
47+
4248
} // namespace v_noabi
4349
} // namespace bsoncxx
4450

src/mongocxx/include/mongocxx/v_noabi/mongocxx/config/compiler.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// TODO: DRY this definition with the one from bsoncxx/config/compiler.hpp per discussion
16-
// here - https://github.com/mongodb/mongo-cxx-driver/pull/374#issuecomment-158179295
17-
#if defined(_MSC_VER)
18-
19-
// Disable MSVC warnings that cause a lot of noise related to DLL visibility
20-
// for types that we don't control (like std::unique_ptr).
21-
#pragma warning(push)
22-
#pragma warning(disable : 4251 4275)
23-
24-
#endif
25-
2615
// For backward compatibility. Use `inline` instead.
2716
#define MONGOCXX_INLINE inline MONGOCXX_ABI_NO_EXPORT
2817

src/mongocxx/include/mongocxx/v_noabi/mongocxx/config/postlude.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
// compiler.hpp
1616
#undef MONGOCXX_INLINE
1717
#pragma pop_macro("MONGOCXX_INLINE")
18-
#if defined(_MSC_VER)
19-
#pragma warning(pop)
20-
#endif
2118
#undef MONGOCXX_CALL
2219
#pragma pop_macro("MONGOCXX_CALL")
2320

src/mongocxx/include/mongocxx/v_noabi/mongocxx/exception/exception.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@
1919

2020
#include <mongocxx/exception/exception-fwd.hpp>
2121

22+
#include <bsoncxx/config/prelude.hpp>
2223
#include <mongocxx/config/prelude.hpp>
2324

2425
namespace mongocxx {
2526
namespace v_noabi {
2627

28+
BSONCXX_PUSH_WARNINGS();
29+
BSONCXX_DISABLE_WARNING(MSVC(4251));
30+
BSONCXX_DISABLE_WARNING(MSVC(4275));
31+
2732
///
2833
/// A class to be used as the base class for all mongocxx exceptions.
2934
///
@@ -39,9 +44,12 @@ class exception : public std::system_error {
3944
using system_error::system_error;
4045
};
4146

47+
BSONCXX_POP_WARNINGS();
48+
4249
} // namespace v_noabi
4350
} // namespace mongocxx
4451

52+
#include <bsoncxx/config/postlude.hpp>
4553
#include <mongocxx/config/postlude.hpp>
4654

4755
///

src/mongocxx/include/mongocxx/v_noabi/mongocxx/exception/operation_exception.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,16 @@
2323
#include <mongocxx/exception/exception.hpp>
2424
#include <mongocxx/stdx.hpp>
2525

26+
#include <bsoncxx/config/prelude.hpp>
2627
#include <mongocxx/config/prelude.hpp>
2728

2829
namespace mongocxx {
2930
namespace v_noabi {
3031

32+
BSONCXX_PUSH_WARNINGS();
33+
BSONCXX_DISABLE_WARNING(MSVC(4251));
34+
BSONCXX_DISABLE_WARNING(MSVC(4275));
35+
3136
///
3237
/// Class representing an exception received from a MongoDB server. It includes the server-provided
3338
/// error code, if one was available.
@@ -84,9 +89,12 @@ class operation_exception : public exception {
8489
stdx::optional<bsoncxx::v_noabi::document::value> _raw_server_error;
8590
};
8691

92+
BSONCXX_POP_WARNINGS();
93+
8794
} // namespace v_noabi
8895
} // namespace mongocxx
8996

97+
#include <bsoncxx/config/postlude.hpp>
9098
#include <mongocxx/config/postlude.hpp>
9199

92100
///

src/mongocxx/include/mongocxx/v_noabi/mongocxx/options/index.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <bsoncxx/string/view_or_value.hpp>
2828
#include <mongocxx/stdx.hpp>
2929

30+
#include <bsoncxx/config/prelude.hpp>
3031
#include <mongocxx/config/prelude.hpp>
3132

3233
namespace mongocxx {
@@ -40,6 +41,10 @@ namespace options {
4041
///
4142
class index {
4243
public:
44+
BSONCXX_PUSH_WARNINGS();
45+
BSONCXX_DISABLE_WARNING(MSVC(4251));
46+
BSONCXX_DISABLE_WARNING(MSVC(4275));
47+
4348
///
4449
/// Base class representing the optional storage engine options for indexes.
4550
///
@@ -97,6 +102,8 @@ class index {
97102
stdx::optional<bsoncxx::v_noabi::string::view_or_value> _config_string;
98103
};
99104

105+
BSONCXX_POP_WARNINGS();
106+
100107
MONGOCXX_ABI_EXPORT_CDECL() index();
101108

102109
///
@@ -537,6 +544,7 @@ class index {
537544
} // namespace v_noabi
538545
} // namespace mongocxx
539546

547+
#include <bsoncxx/config/postlude.hpp>
540548
#include <mongocxx/config/postlude.hpp>
541549

542550
///

0 commit comments

Comments
 (0)