Skip to content

Conversation

@sethk
Copy link
Contributor

@sethk sethk commented Jul 20, 2025

Recent MSVC supports the C11 atomics standard if given /experimental:c11atomics.

The compatibility header libvmaf/src/compat/msvc/stdatomic.h does not work on versions of MSVC which support c11atomics. Even without the /experimental:c11atomics flag, the MSVC version of stdatomic.h is included, but the _Atomic() declaration specifier is not active, so it fails to compile.

The Meson tests here check whether a trivial program that #includes stdatomic.h compiles via cc.check_header(). If that fails, and we're using MSVC, it tries again with /experimental:c11atomics added. The compat headers are only used if stdatomic.h does not exist on the system at all.

-DHAVE_STDATOMIC_H is used to ensure that everywhere stdatomic.h is used, stdatomic_dependency is also added to the Meson target. There were several places where this was missing, meaning that those targets were likely broken for compilers without c11 atomics.

For versions of MSVC before c11atomics support was added, I attempted to fix the compat header, but I don't have a good way to test this. The compat header has been broken for a while because it depends on another internal header, "common/attributes.h", which no longer exists in the project.

sethk and others added 3 commits March 18, 2025 21:40
MSVC has added support for <stdatomic.h>, but it requires passing
/experimental:c11atomics to enable it. Without this flag, the backwards
compatibility header libvmaf/src/compat/msvc/stdatomic.h is used

MSVC has been shipping stdatomic.h since they added
/experimental:c11atomics, but without this flag on for example MSVC
14.42.34433, <stdatomic.h> will be found and #included, but won't work
due to /std:c11 being used without /experimental:c11atomics.

This should be backwards compatible with older MSVC that doesn't support
c11atomics, because the test for stdatomic.h will fail and the compat.
header will be used as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant