Apply __cdecl
to all exported callbacks
#1966
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Apply missing
BSON_CALL
to all exported callbacks to ensure__cdecl
is applied when building with MSVC.Resolves CDRIVER-2737 and CDRIVER-5678.
Verified with this patch build.
Background & Motivation
Existing expectations
This PR assumes libbson and libmongoc do not support building with a non-cdecl calling convention. Attempting to build libbson with /Gv to specify the
__vectorcall
calling convention results in errors:This PR intends to ensure consumers building with MSVC see
__cdecl
in the function declaration when building headers to match the expected calling convention of libmongoc and libbson.Skipping CI testing
Similar to mongodb/mongo-cxx-driver#1202, an attempt was made to build test-libmongoc with
/Gv
to test a non-cdecl consumer.Doing so expectedly appears to require marking all callback functions defined in tests with
__cdecl
to avoid errors like:And also appears to require marking functions in private headers used by tests to be marked
__cdecl
:To expedite the fix, tests in CI are not added.