Skip to content

glib/gmacros.h: Move `<type_traits>` include to consumers

Iain Lane requested to merge iainl/glib:type-traits-glib-min-version into master

When included inside an extern "C" block, this causes build failures that look something like:

/usr/include/c++/10/type_traits:2930:3: error: template with C linkage 2930 | template<typename _Fn, typename... _Args> | ^~~~~~~~ ../../disas/arm-a64.cc:20:1: note: ‘extern "C"’ linkage started here 20 | extern "C" { | ^~~~~~~~~~

Commit 4273c439 made this opt in for projects which are defining GLIB_VERSION_MIN_REQUIRED, but the include of <type_traits> via gmacros.h was not included in this. If we move the include out to the places where glib_typeof is called, we can make it covered by this macro too, and save a few consumers from FTBFSing.

That also means that, if you don't want to fix your use of the headers, and as long as this version is sufficient for you, a quick workaround is to define GLIB_VERSION_MIN_REQUIRED to GLIB_VERSION_2_66 or lower.

Suggested by Simon McVittie.

Alternative to: !1935 (closed) Fixes: #2331 (closed)

Merge request reports