Skip to content

Commit 591e46d

Browse files
authored
Apply __cdecl to all exported functions (CXX-3092, CXX-3093) (#1202)
* Restrict macro guard tests to public headers * Redefine export header macros in terms of ABI visibility * Address -Wreserved-macro-identifier warnings in macro guard tests * Disable -Wunused-macros warning for macro guard tests * CXX-3093 Replace BSONCXX_API -> BSONCXX_ABI_EXPORT_CDECL * CXX-3093 Replace MONGOCXX_API -> MONGOCXX_ABI_EXPORT_CDECL * Address -Wweak-vtables warnings for exception classes * Add __cdecl to main() in examples * Include __cdecl in specialization of mongocxx::test_util::mock * Include __cdecl in std::function<T> for exported symbols * CDRIVER-5789 Workaround missing __cdecl in mongoc_log_func_t * CXX-3093 Add changelog entry for ABI symbol removal * CXX-3092 Enable /Gv when building test suite with MSVC * doxygen: set ALWAYS_DETAILED_SEC = YES * doxygen: set STRICT_PROTO_MATCHING = YES * Disable C4251 and C4275 warnings for exception classes * Scope "Downloading" messages to avoid misleading repeated output * Also update debian_package_build.sh with examples include directory * Remove private and generated config headers from macro guard tests * Add coding guidelines section for virtual functions * Add missing __cdecl in value::deleter_type declarations * Remove stray use of MONGOCXX_CALL
1 parent fb26981 commit 591e46d

File tree

356 files changed

+3757
-2740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

356 files changed

+3757
-2740
lines changed

.evergreen/build_snapshot_rpm.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ sudo mock -r ${config} --use-bootstrap-image --isolation=simple --copyin "${mock
124124

125125
sudo mock -r ${config} --use-bootstrap-image --isolation=simple --cwd "/tmp/${build_dir}" --chroot -- /bin/sh -c "(
126126
rpm -Uvh ../mock-result/*.rpm &&
127-
/usr/bin/g++ -I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -o runcommand_examples examples/mongocxx/mongodb.com/runcommand_examples.cpp -lmongocxx -lbsoncxx &&
128-
/usr/bin/g++ -I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -o aggregation_examples examples/mongocxx/mongodb.com/aggregation_examples.cpp -lmongocxx -lbsoncxx &&
129-
/usr/bin/g++ -I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -o index_examples examples/mongocxx/mongodb.com/index_examples.cpp -lmongocxx -lbsoncxx &&
130-
/usr/bin/g++ -I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -o documentation_examples examples/mongocxx/mongodb.com/documentation_examples.cpp -lmongocxx -lbsoncxx
127+
/usr/bin/g++ -I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -I. -o runcommand_examples examples/mongocxx/mongodb.com/runcommand_examples.cpp -lmongocxx -lbsoncxx &&
128+
/usr/bin/g++ -I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -I. -o aggregation_examples examples/mongocxx/mongodb.com/aggregation_examples.cpp -lmongocxx -lbsoncxx &&
129+
/usr/bin/g++ -I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -I. -o index_examples examples/mongocxx/mongodb.com/index_examples.cpp -lmongocxx -lbsoncxx &&
130+
/usr/bin/g++ -I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -I. -o documentation_examples examples/mongocxx/mongodb.com/documentation_examples.cpp -lmongocxx -lbsoncxx
131131
)"
132132

133133
if [ ! -e "${mock_root}/tmp/${build_dir}/runcommand_examples" ]; then

.evergreen/debian_package_build.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,13 @@ sudo DEB_BUILD_PROFILES="${DEB_BUILD_PROFILES}" chroot ./unstable-chroot /bin/ba
7777
LANG=C /bin/bash -x ./debian/build_snapshot.sh && \
7878
debc ../*.changes && \
7979
dpkg -i ../*.deb && \
80-
/usr/bin/g++ ${MNMLSTC_INCLUDE:-}-I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -o runcommand_examples examples/mongocxx/mongodb.com/runcommand_examples.cpp -lmongocxx -lbsoncxx && \
81-
/usr/bin/g++ ${MNMLSTC_INCLUDE:-}-I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -o aggregation_examples examples/mongocxx/mongodb.com/aggregation_examples.cpp -lmongocxx -lbsoncxx && \
82-
/usr/bin/g++ ${MNMLSTC_INCLUDE:-}-I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -o index_examples examples/mongocxx/mongodb.com/index_examples.cpp -lmongocxx -lbsoncxx && \
83-
/usr/bin/g++ ${MNMLSTC_INCLUDE:-}-I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -o documentation_examples examples/mongocxx/mongodb.com/documentation_examples.cpp -lmongocxx -lbsoncxx )"
80+
/usr/bin/g++ ${MNMLSTC_INCLUDE:-}-I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -I. -o runcommand_examples examples/mongocxx/mongodb.com/runcommand_examples.cpp -lmongocxx -lbsoncxx && \
81+
/usr/bin/g++ ${MNMLSTC_INCLUDE:-}-I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -I. -o aggregation_examples examples/mongocxx/mongodb.com/aggregation_examples.cpp -lmongocxx -lbsoncxx && \
82+
/usr/bin/g++ ${MNMLSTC_INCLUDE:-}-I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -I. -o index_examples examples/mongocxx/mongodb.com/index_examples.cpp -lmongocxx -lbsoncxx && \
83+
/usr/bin/g++ ${MNMLSTC_INCLUDE:-}-I/usr/include/bsoncxx/v_noabi -I/usr/include/mongocxx/v_noabi -I. -o documentation_examples examples/mongocxx/mongodb.com/documentation_examples.cpp -lmongocxx -lbsoncxx )"
8484

8585
[ -e ./unstable-chroot/tmp/mongo-cxx-driver/runcommand_examples ] || (echo "Example 'runcommand_examples' was not built!" ; exit 1)
8686
[ -e ./unstable-chroot/tmp/mongo-cxx-driver/aggregation_examples ] || (echo "Example 'aggregation_examples' was not built!" ; exit 1)
8787
[ -e ./unstable-chroot/tmp/mongo-cxx-driver/index_examples ] || (echo "Example 'index_examples' was not built!" ; exit 1)
8888
[ -e ./unstable-chroot/tmp/mongo-cxx-driver/documentation_examples ] || (echo "Example 'documentation_examples' was not built!" ; exit 1)
8989
(cd ./unstable-chroot/tmp/ ; tar zcvf ../../deb.tar.gz *.dsc *.orig.tar.gz *.debian.tar.xz *.build *.deb)
90-

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu
2222
- A future minor release plans to raise the minimum supported MongoDB Server version from 3.6 to 4.0. This is in
2323
accordance with [MongoDB Software Lifecycle Schedules](https://www.mongodb.com/legal/support-policy/lifecycles).
2424

25+
### Removed
26+
27+
- Export of private member functions in bsoncxx:
28+
- `bsoncxx::v_noabi::types::bson_value::value::value(const uint8_t*, uint32_t, uint32_t, uint32_t)`
29+
- `bsoncxx::v_noabi::types::bson_value::view::_init(void*)`
30+
- `bsoncxx::v_noabi::types::bson_value::view::view(const uint8_t*, uint32_t, uint32_t, uint32_t)`
31+
- `bsoncxx::v_noabi::types::bson_value::view::view(void*)`
32+
- Export of private member functions in mongocxx:
33+
- `mongocxx::v_noabi::options::change_stream::as_bson()`
34+
- `mongocxx::v_noabi::options::aggregate::append(bsoncxx::v_noabi::builder::basic::document&)`
35+
- `mongocxx::v_noabi::options::index::storage_options()`
36+
2537
## 3.10.3 [Unreleased]
2638

2739
<!-- Will contain entries for the next patch release -->

Doxyfile

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ ABBREVIATE_BRIEF =
153153
# description.
154154
# The default value is: NO.
155155

156-
ALWAYS_DETAILED_SEC = NO
156+
ALWAYS_DETAILED_SEC = YES
157157

158158
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
159159
# inherited members of a class in the documentation of that class as if those
@@ -726,7 +726,7 @@ SORT_BY_SCOPE_NAME = YES
726726
# accept a match between prototype and implementation in such cases.
727727
# The default value is: NO.
728728

729-
STRICT_PROTO_MATCHING = NO
729+
STRICT_PROTO_MATCHING = YES
730730

731731
# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
732732
# list. This list is created by putting \todo commands in the documentation.
@@ -2417,15 +2417,9 @@ INCLUDE_FILE_PATTERNS =
24172417
# recursively expanded use the := operator instead of the = operator.
24182418
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
24192419

2420-
PREDEFINED = BSONCXX_API= \
2421-
BSONCXX_CALL= \
2422-
BSONCXX_DEPRECATED \
2423-
BSONCXX_INLINE=inline \
2420+
PREDEFINED = BSONCXX_ABI_EXPORT_CDECL(...)=__VA_ARGS__ \
24242421
BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR= \
2425-
MONGOCXX_API= \
2426-
MONGOCXX_CALL= \
2427-
MONGOCXX_DEPRECATED= \
2428-
MONGOCXX_INLINE=inline \
2422+
MONGOCXX_ABI_EXPORT_CDECL(...)=__VA_ARGS__ \
24292423
MONGOCXX_PRIVATE_DOXYGEN_PREPROCESSOR=
24302424

24312425
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
@@ -2435,7 +2429,26 @@ PREDEFINED = BSONCXX_API= \
24352429
# definition found in the source code.
24362430
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
24372431

2438-
EXPAND_AS_DEFINED =
2432+
EXPAND_AS_DEFINED = BSONCXX_ABI_CDECL \
2433+
BSONCXX_ABI_EXPORT \
2434+
BSONCXX_ABI_NO_EXPORT \
2435+
BSONCXX_API \
2436+
BSONCXX_CALL \
2437+
BSONCXX_DEPRECATED \
2438+
BSONCXX_DEPRECATED_EXPORT \
2439+
BSONCXX_DEPRECATED_NO_EXPORT \
2440+
BSONCXX_INLINE \
2441+
BSONCXX_PRIVATE \
2442+
MONGOCXX_ABI_CDECL \
2443+
MONGOCXX_ABI_EXPORT \
2444+
MONGOCXX_ABI_NO_EXPORT \
2445+
MONGOCXX_API \
2446+
MONGOCXX_CALL \
2447+
MONGOCXX_DEPRECATED \
2448+
MONGOCXX_DEPRECATED_EXPORT \
2449+
MONGOCXX_DEPRECATED_NO_EXPORT \
2450+
MONGOCXX_INLINE \
2451+
MONGOCXX_PRIVATE
24392452

24402453
# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
24412454
# remove all references to function-like macros that are alone on a line, have

benchmark/microbench.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ bool finished_running(const std::chrono::duration<std::uint32_t, std::milli>& cu
2626
return (curr_time > maxtime || (curr_time > mintime && iter > max_iter));
2727
}
2828

29+
microbench::~microbench() = default;
30+
2931
void microbench::run() {
3032
setup();
3133

benchmark/microbench.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ class microbench {
6767
microbench(std::string&& name, double task_size, std::set<benchmark_type> tags = {})
6868
: _score{task_size}, _tags{tags}, _name{std::move(name)} {}
6969

70-
virtual ~microbench() = default;
70+
virtual ~microbench();
71+
72+
microbench(microbench&&) = default;
73+
microbench& operator=(microbench&&) = default;
74+
microbench(const microbench&) = default;
75+
microbench& operator=(const microbench&) = default;
7176

7277
void run();
7378

cmake/FetchCatch2.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ function(fetch_catch2)
3030
string(REPLACE " -Werror" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
3131
string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
3232

33+
# Ensure consistent default calling convention with test executables.
34+
if(MSVC)
35+
string(APPEND CMAKE_CXX_FLAGS " /Gv")
36+
endif()
37+
3338
FetchContent_MakeAvailable(EP_Catch2)
3439

3540
# Avoid building unnecessary targets. Use FetchContent_Declare(EXCLUDE_FROM_ALL) in CMake 3.28 and newer.

cmake/MacroGuardTest.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,19 @@ function(add_macro_guard_test)
8080
"static_assert(compare_equal(\"abc\", \"abc\"), \"compare_equal() sanity check failed\");\n"
8181
"static_assert(!compare_equal(\"abc\", \"def\"), \"compare_equal() sanity check failed\");\n"
8282
"\n"
83-
"#define _TO_STR(x) #x\n"
84-
"#define TO_STR(x) _TO_STR(x)\n"
83+
"#define TO_STR_1(x) #x\n"
84+
"#define TO_STR(x) TO_STR_1(x)\n"
8585
"\n"
8686
)
8787

8888
add_library(test_${PARSED_PROJECT_NAME}_macro_guards STATIC EXCLUDE_FROM_ALL)
8989
target_link_libraries(test_${PARSED_PROJECT_NAME}_macro_guards PRIVATE ${PARSED_PROJECT_TEST_PROPERTIES_TARGET})
9090

91+
# Avoid noisy warnings.
92+
target_compile_options(test_${PARSED_PROJECT_NAME}_macro_guards PRIVATE
93+
$<$<CXX_COMPILER_ID:GNU,Clang>:-Wno-unused-macros>
94+
)
95+
9196
# Test each header individually.
9297
foreach(header ${GUARDED_HEADERS})
9398
set(MACRO_GUARD_TEST "${MACRO_GUARD_TEST_PRELUDE}")

etc/coding_guidelines.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,9 @@ class foo {
144144
## Relational Operators
145145

146146
- Prefer to use free functions
147+
148+
## Virtual Functions
149+
150+
- Define at least one virtual function out-of-line in a source file as the "key function" for the polymorphic class to avoid weak vtables.
151+
- Use the virtual destructor as the key function if no other appropriate virtual function exists.
152+
- Ensure all copy and move special member functions are defaulted, deleted, or defined if the virtual destructor is defined out-of-line.

examples/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ function(add_examples_executable source)
6666
add_executable(${target_name} EXCLUDE_FROM_ALL ${source})
6767
target_link_libraries(${target_name} PRIVATE ${PARSED_LIBRARIES})
6868

69+
# Permit `#include <examples/macros.hh>`.
70+
target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
71+
6972
# Keep executables in separate directories.
7073
set_target_properties(${target_name} PROPERTIES
7174
OUTPUT_NAME ${name}
7275
RUNTIME_OUTPUT_DIRECTORY ${subdir}
7376
)
7477

75-
# Deliberately use `__vectorcall` by default with MSVC to catch missing `__cdecl`.
78+
# Use `__vectorcall` by default with MSVC to catch missing `__cdecl`.
7679
target_compile_options(${target_name} PRIVATE "$<$<CXX_COMPILER_ID:MSVC>:/Gv>")
7780

7881
# Keep build and run targets completely separate.
@@ -123,6 +126,12 @@ file(GLOB_RECURSE mongocxx_examples_sources
123126
"mongocxx/*.cpp"
124127
)
125128

129+
file(GLOB_RECURSE examples_headers
130+
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
131+
CONFIGURE_DEPENDS
132+
"*.hh"
133+
)
134+
126135
foreach(source ${api_examples_sources})
127136
add_examples_executable(${source} LIBRARIES mongocxx_target)
128137
endforeach()
@@ -155,6 +164,7 @@ set_local_dist (examples_DIST_local
155164
${api_examples_sources}
156165
${bsoncxx_examples_sources}
157166
${mongocxx_examples_sources}
167+
${examples_headers}
158168
README.md
159169
add_subdirectory/.gitignore
160170
add_subdirectory/CMakeLists.txt

examples/bsoncxx/builder_basic.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
#include <bsoncxx/builder/basic/kvp.hpp>
2020
#include <bsoncxx/types.hpp>
2121

22+
#include <examples/macros.hh>
23+
2224
using namespace bsoncxx;
2325

24-
int main() {
26+
int EXAMPLES_CDECL main() {
2527
// bsoncxx::builder::basic presents a BSON-construction interface familiar to users of the
2628
// server's
2729
// BSON library or the Java driver.

examples/bsoncxx/builder_core.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
#include <bsoncxx/builder/core.hpp>
1616
#include <bsoncxx/types.hpp>
1717

18+
#include <examples/macros.hh>
19+
1820
using namespace bsoncxx;
1921

20-
int main() {
22+
int EXAMPLES_CDECL main() {
2123
// bsoncxx::builder::core is a low-level primitive that can be useful for building other
2224
// BSON abstractions. Most users should just use builder::stream or builder::basic.
2325

examples/bsoncxx/builder_list.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
#include <bsoncxx/types.hpp>
1919
#include <bsoncxx/types/bson_value/value.hpp>
2020

21+
#include <examples/macros.hh>
22+
2123
using namespace bsoncxx;
2224

23-
int main() {
25+
int EXAMPLES_CDECL main() {
2426
using namespace bsoncxx::builder;
2527

2628
//

examples/bsoncxx/builder_stream.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
#include <bsoncxx/builder/stream/helpers.hpp>
1818
#include <bsoncxx/types.hpp>
1919

20+
#include <examples/macros.hh>
21+
2022
using namespace bsoncxx;
2123

22-
int main() {
24+
int EXAMPLES_CDECL main() {
2325
using builder::stream::array;
2426
using builder::stream::document;
2527

examples/bsoncxx/builder_stream_customization.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <bsoncxx/builder/stream/document.hpp>
2020
#include <bsoncxx/json.hpp>
2121

22+
#include <examples/macros.hh>
23+
2224
using namespace bsoncxx;
2325

2426
// concatenates arbitrary ranges into an array context
@@ -68,7 +70,7 @@ range_kvp_appender<begin_t, end_t> make_range_kvp_appender(begin_t&& begin, end_
6870
std::forward<end_t>(end));
6971
}
7072

71-
int main() {
73+
int EXAMPLES_CDECL main() {
7274
using builder::stream::array;
7375
using builder::stream::document;
7476
using builder::stream::finalize;

examples/bsoncxx/decimal128.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
#include <bsoncxx/exception/exception.hpp>
2121
#include <bsoncxx/types.hpp>
2222

23+
#include <examples/macros.hh>
24+
2325
using namespace bsoncxx;
2426

25-
int main() {
27+
int EXAMPLES_CDECL main() {
2628
// Convert a string to BSON Decimal128.
2729
decimal128 d128;
2830
try {

examples/bsoncxx/getting_values.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121

2222
#include <bsoncxx/config/prelude.hpp>
2323

24+
#include <examples/macros.hh>
25+
2426
using namespace bsoncxx;
2527

26-
int main() {
28+
int EXAMPLES_CDECL main() {
2729
using namespace builder::stream;
2830

2931
builder::stream::document build_doc;

examples/bsoncxx/view_and_value.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
#include <bsoncxx/types.hpp>
3030
#include <bsoncxx/types/bson_value/view.hpp>
3131

32+
#include <examples/macros.hh>
33+
3234
using namespace bsoncxx;
3335

34-
int main() {
36+
int EXAMPLES_CDECL main() {
3537
// This example will cover the read-only BSON interface.
3638

3739
// Lets first build up a non-trivial BSON document using the builder interface.

examples/macros.hh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2009-present MongoDB, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#pragma once
16+
17+
#if defined(_MSC_VER)
18+
#define EXAMPLES_CDECL __cdecl
19+
#else
20+
#define EXAMPLES_CDECL
21+
#endif

examples/mongocxx/aggregate.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
#include <mongocxx/pipeline.hpp>
2323
#include <mongocxx/uri.hpp>
2424

25+
#include <examples/macros.hh>
26+
2527
using bsoncxx::builder::basic::kvp;
2628
using bsoncxx::builder::basic::make_document;
2729

28-
int main() {
30+
int EXAMPLES_CDECL main() {
2931
// The mongocxx::instance constructor and destructor initialize and shut down the driver,
3032
// respectively. Therefore, a mongocxx::instance must be created before using the driver and
3133
// must remain alive for as long as the driver is in use.

examples/mongocxx/automatic_client_side_field_level_encryption.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include <mongocxx/options/data_key.hpp>
3333
#include <mongocxx/options/encrypt.hpp>
3434

35+
#include <examples/macros.hh>
36+
3537
using bsoncxx::builder::basic::kvp;
3638
using bsoncxx::builder::basic::make_document;
3739

@@ -97,7 +99,7 @@ bsoncxx::document::value doc_from_file(std::string path) {
9799

98100
} // namespace
99101

100-
int main() {
102+
int EXAMPLES_CDECL main() {
101103
instance inst{};
102104

103105
// This must be the same master key that was used to create

examples/mongocxx/bulk_write.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
#include <mongocxx/instance.hpp>
2323
#include <mongocxx/uri.hpp>
2424

25+
#include <examples/macros.hh>
26+
2527
using bsoncxx::builder::basic::kvp;
2628
using bsoncxx::builder::basic::make_document;
2729

28-
int main() {
30+
int EXAMPLES_CDECL main() {
2931
// The mongocxx::instance constructor and destructor initialize and shut down the driver,
3032
// respectively. Therefore, a mongocxx::instance must be created before using the driver and
3133
// must remain alive for as long as the driver is in use.

0 commit comments

Comments
 (0)