Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: VS2022 compatibility (Read 604 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

VS2022 compatibility

Recently, I updated VS2022 Community Edition to version 17.10.1 and found that component compiled with /MD using the msvcp140.dll included in the foobar2000 installation crash in some cases. However, there are no issues when using the system-installed msvcp140.dll. My current solution is to set the MSVC toolset version to 14.36.32532 (the current default is 14.40.33807, and other versions have not been tested).

I would like to ask if there are any better solutions(except using /MT compilation) to handle this problem so that future updates or project configurations do not need to focus on the toolset version?

test code(/MD and using bundled msvcp140.dll):
Code: [Select]
#include <mutex>
int main()
{
    std::mutex mutex;
    // Access violation
    mutex.lock();
    return 0;
}

Re: VS2022 compatibility

Reply #1
The breaking change re: std::mutex is documented here...

https://github.com/microsoft/STL/wiki/Changelog#vs-2022-1710

If you really don't want to static link, this is the workaround...

Code: [Select]
#define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR

But I updated all my projects to static link from now on. Only a few use std::mutex and most do not but I figured I would protect myself from getting burned by anything else in future.


Re: VS2022 compatibility

Reply #2
I would highly recommend against using static linking. There is a limit in number of DLLs the player can load that are linked that way, which was already a problem many years ago. If you must use std::mutex and don't want to use older toolchain or the compatibility setting, then of course that is your only option. Also note that new foobar2000 releases should bundle the latest runtime at the time of release.


 

Re: VS2022 compatibility

Reply #4
The breaking change re: std::mutex is documented here...

https://github.com/microsoft/STL/wiki/Changelog#vs-2022-1710

If you really don't want to static link, this is the workaround...

Code: [Select]
#define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR

But I updated all my projects to static link from now on. Only a few use std::mutex and most do not but I figured I would protect myself from getting burned by anything else in future.


Thanks! That's helpful.