steinbergmedia / vst3_pluginterfaces

VST 3 API
Other
24 stars 18 forks source link

Fix ‘atomic_int_least32_t’ does not name a type compilation error #12

Closed theartful closed 1 year ago

theartful commented 1 year ago

std::atomic_int_least32_t is defined in atomic header, and not stdatomic. This caused compilation error locally on gcc 12.2.0.

scheffle commented 1 year ago

See https://en.cppreference.com/w/c/thread#Atomic_operations, atomic_int_least32_t must be part of the stdatomic.h header. And looking at the source of https://github.com/gcc-mirror/gcc/blob/releases/gcc-12/gcc/ginclude/stdatomic.h it is included there. Please check your installation.

theartful commented 1 year ago

@scheffle This is weird. This simple example doesn't compile locally

#include <stdatomic.h>

int main() {
    atomic_int_least32_t x;
}

nor on godbolt: https://godbolt.org/z/cKz1c8GeT

theartful commented 1 year ago

The header changed in the latest gcc: https://gcc.gnu.org/onlinedocs/libstdc%2B%2B/latest-doxygen/a00017_source.html I'm using a rolling release distro, and it seems they removed these typedefs and breaking the standard? Anyways, this patch fixed the issue for me.

theartful commented 1 year ago

The problem is with this part of the header

#if __cplusplus > 202002L

for some reason the header shipped on my distro and on godbolt requires at least c++23 to work. Passing "-std=c++23" makes the example compile. Anyways, I think this is my gcc's installation fault, since the standard requires these typedefs.

scheffle commented 1 year ago

Thanks for the update, that's good to know. We will try to support GCC 12 with one of our next releases.

theartful commented 1 year ago

Ok, so it seems that c++ compilers supported stdatomic, when they didn't have to. Starting from C++23, they have to support it. See https://en.cppreference.com/w/cpp/23, which means that stdatomic wasn't standard compliant before. MSVC STL also made the same changes, see: https://github.com/microsoft/STL/blob/e28f9561233a58d48d893094ed3a6bc0c5ee6ad9/stl/inc/__msvc_cxx_stdatomic.hpp#L24-L27