gmacros: Define G_CXX_STD_VERSION and check macros

Sadly, in C++ there's not an universal way to get what language standard
is used to compile GLib-based programs, in fact while most compilers
relies on `__cplusplus`, MSVC is defining that, but it does not use it
to expose such information (unless `/Zc:__cplusplus` arg is used).
On the other side, MSVC reports the language standard via _MSVC_LANG [1].

This complication makes us defining some macros in a very complex way
(such as glib_typeof()), because we need to perform many checks just to
understand if a C++ compiler is used and what standard is expecting.

To avoid this, define multiple macros that can be used to figure out
what C++ standard is being used.

[1] https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170
This commit is contained in:
Marco Trevisan (Treviño)
2022-09-14 01:03:22 +02:00
parent 054b96fd09
commit f9845abe39
6 changed files with 187 additions and 2 deletions

View File

@@ -410,6 +410,10 @@ G_HAVE_GNUC_VISIBILITY
G_GNUC_INTERNAL
G_GNUC_MAY_ALIAS
<SUBSECTION>
G_CXX_STD_VERSION
G_CXX_STD_CHECK_VERSION
<SUBSECTION>
G_DEPRECATED
G_DEPRECATED_FOR