@@ -312,11 +312,22 @@ struct type_info {
312
312
313
313
// / On Linux/OSX, changes in __GXX_ABI_VERSION__ indicate ABI incompatibility.
314
314
// / 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
315
318
#ifndef PYBIND11_BUILD_ABI
316
319
# if defined(__GXX_ABI_VERSION)
317
320
# 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"
318
329
# 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"
320
331
# elif defined(_MSC_VER) && defined(_MT)
321
332
# define PYBIND11_BUILD_ABI " _mt_mscver" PYBIND11_TOSTRING(_MSC_VER)
322
333
# else
0 commit comments