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 3895 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.


Re: VS2022 compatibility

Reply #6
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.
That was exactly my case: I wanted to use latest C++ features and third-party libraries that rely on those features, but foobar2000 release cycle (and thus toolchain update cycle) was much slower than VS updates - sometimes it took more than a half a year to catch up. Also, I might be mistaken, but I think fb2k does not (did not?) even always use the latest version of toolchain.

(...)upcoming release (17.12) is dropping support for targetting windows 7.
A major oof... Not that it was unexpected, but still...


Re: VS2022 compatibility

Reply #8
They've changed their minds on dropping win7 targetting in VS2022.

Before: "gotten approval from my bosses and boss-like entities"

After: "My ultrabosses have decided" xDDD

But it is getting nuked in the next major version

Thankfully, probability of "next major version" appearing in the near future is quite low (because MS/VS management understandably do not want to break back-compatibility).

Thanks for finding all these tit-bits :)

Re: VS2022 compatibility

Reply #9
TheQwertiest, they follow roughly 3-year release cycle and most probably the next major version will be released this or next year.

Re: VS2022 compatibility

Reply #10
I think you are confusing two things: VS IDE release and MSVC compiler major version change (https://learn.microsoft.com/en-us/cpp/overview/compiler-versions?view=msvc-170#version-macros).
They've been keeping major version the same for at least 9 years.
And while I believe that compatibility break *will* happen one day, I have huge doubts that it will be done any time soon, because there is just no good enough reason to justify such a huge break for their business customers.


Nevermind, it's me who can't read:  "dropping support has been approved for the 18.0 Preview", i.e. it's VS IDE and not compiler version

Re: VS2022 compatibility

Reply #11
Current MSVC compiler version is v14.3. They dropped Windows XP in a minor update from v14.0 to v14.1, nothing prevents them from dropping Windows 7 in v14.4. In fact, the MSVC developers are considering to make an incompatible update for C runtime for a few years already, so it might be a major update. It's just their ultrabosses not allowing to do it yet. BTW, they also want to make the runtime open source, waiting for another ultrabosses approval =)

Re: VS2022 compatibility

Reply #12
Thankfully, probability of "next major version" appearing in the near future is quite low

Or maybe not.

https://github.com/microsoft/STL/wiki/Changelog#expected-in-vs-meow-preview-1

This link will break when the next version gets a name.