Skip to content

Commit 10dd08a

Browse files
committed
Fix preprocessor
1 parent 12a6478 commit 10dd08a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

include/pybind11/detail/internals.h

+12-1
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,22 @@ struct type_info {
312312

313313
/// On Linux/OSX, changes in __GXX_ABI_VERSION__ indicate ABI incompatibility.
314314
/// On MSVC, mixing /MT and /MD will result in crashes. See (#4953)
315+
/// There is no macro for major version for MSVC, so we check for major version
316+
/// 19, 20, 21, 22 for now as major version 19 is MSVC 2015-2022 and we future
317+
/// proof for 3 major versions in the future
315318
#ifndef PYBIND11_BUILD_ABI
316319
# if defined(__GXX_ABI_VERSION)
317320
# define PYBIND11_BUILD_ABI "_cxxabi" PYBIND11_TOSTRING(__GXX_ABI_VERSION)
321+
# elif defined(_MSC_VER) && defined(_DLL) && defined(_MT) && ((_MSC_VER) / 100 == 19)
322+
# define PYBIND11_BUILD_ABI "_md_mscver19"
323+
# elif defined(_MSC_VER) && defined(_DLL) && defined(_MT) && ((_MSC_VER) / 100 == 20)
324+
# define PYBIND11_BUILD_ABI "_md_mscver20"
325+
# elif defined(_MSC_VER) && defined(_DLL) && defined(_MT) && ((_MSC_VER) / 100 == 21)
326+
# define PYBIND11_BUILD_ABI "_md_mscver21"
327+
# elif defined(_MSC_VER) && defined(_DLL) && defined(_MT) && ((_MSC_VER) / 100 == 22)
328+
# define PYBIND11_BUILD_ABI "_md_mscver22"
318329
# elif defined(_MSC_VER) && defined(_DLL) && defined(_MT)
319-
# define PYBIND11_BUILD_ABI "_md_mscver" PYBIND11_TOSTRING(((int) (_MSC_VER) / 100))
330+
# error "Unknown major version for MSC_VER"
320331
# elif defined(_MSC_VER) && defined(_MT)
321332
# define PYBIND11_BUILD_ABI "_mt_mscver" PYBIND11_TOSTRING(_MSC_VER)
322333
# else

0 commit comments

Comments
 (0)