Skip to content

meson: Use check_header to confirm headers work

instead of using has_header use check_header to confirm the header works. This is necessary to get the meson build to work with Visual Studio 2022. It has <stdatomic.h> but it does not actually work when compiling a C program. A minimal C program that include <stdatomic.h> fails with the following errors:

C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(36): error C2061: syntax error: identifier 'atomic_bool'
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(36): error C2059: syntax error: ';'
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(37): error C2061: syntax error: identifier 'atomic_char'
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(37): error C2059: syntax error: ';'
...
...

check_header is consistent with CMake's

check_include_file(stdatomic.h  HAVE_STDATOMIC_H)

which is why the CMake-based build of dbus works with Visual Studio 2022, while the meson build doesn't.

Fixes #494 (closed)

Merge request reports