Last active
September 28, 2025 04:59
-
-
Save ynkdir/24725274e374fac44f4fbfc5ad79aaf2 to your computer and use it in GitHub Desktop.
There are multiple versions of msvcp140.dll. And they are not forward compatible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // There are multiple versions of msvcp140.dll. | |
| // If C++ program is compiled with newer version, it will not work with older | |
| // version of msvcp140.dll. | |
| // | |
| // You can check file version with PS> (Get-Item msvcp140.dll).VersionInfo | |
| // | |
| // https://learn.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017?view=msvc-170 | |
| // ``` | |
| // C++ binary compatibility between Visual Studio versions | |
| // ... | |
| // Restrictions on binary compatibility | |
| // | |
| // The Redistributable your app uses has a similar binary-compatibility | |
| // restriction. When you mix binaries built by different supported versions of | |
| // the toolset, the Redistributable version must be at least as new as the | |
| // latest toolset used by any app component. | |
| // ``` | |
| // | |
| // The following program will crash when it run with msvcp140.dll older than it compiled with. | |
| // | |
| // For mutex, compile flag /D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR will fix the problem. | |
| // | |
| // https://github.com/microsoft/STL/issues/4730 | |
| #include <iostream> | |
| #include <mutex> | |
| std::mutex mtx; | |
| void testmethod() { | |
| std::scoped_lock lock{ mtx }; | |
| std::cout << "lock worked!\n"; | |
| } | |
| int main() | |
| { | |
| std::cout << "Start!\n"; | |
| testmethod(); | |
| std::cout << "End!\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment