This is a follow-up question to TryAcquireSRWLock* and _WIN32_WINNT
As it seems there is a bug in the Windows SDK 8.1 and newer (up to at least the current 10.0.16299.0) making the methods TryAcquireSRWLockShared and TryAcquireSRWLockExclusive available for compilations targeting Windows Vista or Windows Server 2008. This causes applications containing calls to these methods being unable to execute on Windows Vista or Windows Server 2008 since they are ultimately only available starting from Windows 7 or Windows Server 2008 R2.
It seems that the implementation of std::shared_mutex in the Windows SDK 8.1 makes use of TryAcquireSRWLockShared and TryAcquireSRWLockExclusive. Thus using std::shared_mutex renders the application unable to execute on Windows Vista or Windows Server 2008.
The documentation also states
Warning
Beginning in Visual Studio 2015, the C++ Standard Library synchronization types are based on Windows synchronization primitives and no longer use ConcRT (except when the target platform is Windows XP). The types defined in <shared_mutex> should not be used with any ConcRT types or functions.
However, when using the platform toolset v140_xp the compiler complains about not knowing std::shared_mutex at all.
How can I use std::shared_mutex and still target Windows Vista or Windows Server 2008?
I think you can't. But you can use alternate implementations. There's boost::shared_mutex
. Or if you are using Qt, you can use QReadWriteLock.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With