Skip to content

Expose C and C++ standard versions and add macros to check them

Marco Trevisan requested to merge 3v1n0/glib:c-cxx-std-versions into main

We've various definitions that are depending on C and C++ features that may not work in all the standard versions, we're doing this currently with lots of repeated if's that may lead to troubles in some cases (as underlined by !2864 (merged)). The problem is especially in the C++ case, where we might have not supported some options because how MSVC behaves differently.

So, I'm introducing here (a part of tests, that should be ideally land earlier with !2864 (merged)):

G_CXX_STD_VERSION // defined only when compiling with C++ compiler
G_C_STD_VERSION // defined only when compiling with C compiler

// to check if the compiler supports a standard version, using nice versions:
// such as '90', '11', ...
G_CXX_STD_CHECK_VERSION(17)
G_C_STD_CHECK_VERSION(90)

My idea is to keep these as an internal API, as I'm not sure there's much need for GLib users for them, but we can change that if needed.

Edited by Marco Trevisan

Merge request reports