gmacros.h: Fix C++ macros for Visual Studio

,,,for G_ALWAYS_INLINE and G_NO_INLINE, since the msvc::forceinline and
msvc::noinline attributes require C++-20 support, not just C++-11
support.  This will avoid warning C5051 (unsupported attribute ...,
ignored) if pre-C++-20 was used.
This commit is contained in:
Chun-wei Fan 2023-02-21 14:45:36 +08:00
parent 994209dbee
commit c8730dc6f9

View File

@ -1157,7 +1157,7 @@
# endif # endif
#elif defined (_MSC_VER) #elif defined (_MSC_VER)
/* Use MSVC specific syntax. */ /* Use MSVC specific syntax. */
# if G_CXX_STD_CHECK_VERSION (11) && _MSC_VER >= 1927 # if G_CXX_STD_CHECK_VERSION (20) && _MSC_VER >= 1927
# define G_ALWAYS_INLINE [[msvc::forceinline]] # define G_ALWAYS_INLINE [[msvc::forceinline]]
# else # else
# define G_ALWAYS_INLINE __forceinline # define G_ALWAYS_INLINE __forceinline
@ -1202,7 +1202,7 @@
# if defined (__GNUC__) # if defined (__GNUC__)
# define G_NO_INLINE [[gnu::noinline]] # define G_NO_INLINE [[gnu::noinline]]
# elif defined (_MSC_VER) # elif defined (_MSC_VER)
# if _MSC_VER >= 1927 # if G_CXX_STD_CHECK_VERSION (20) && _MSC_VER >= 1927
# define G_NO_INLINE [[msvc::noinline]] # define G_NO_INLINE [[msvc::noinline]]
# else # else
# define G_NO_INLINE __declspec (noinline) # define G_NO_INLINE __declspec (noinline)
@ -1214,7 +1214,7 @@
#elif defined (_MSC_VER) && (1200 <= _MSC_VER) #elif defined (_MSC_VER) && (1200 <= _MSC_VER)
/* Use MSVC specific syntax. */ /* Use MSVC specific syntax. */
/* Use ISO C++11 syntax when the compiler supports it. */ /* Use ISO C++11 syntax when the compiler supports it. */
# if G_CXX_STD_CHECK_VERSION (11) && _MSC_VER >= 1927 # if G_CXX_STD_CHECK_VERSION (20) && _MSC_VER >= 1927
# define G_NO_INLINE [[msvc::noinline]] # define G_NO_INLINE [[msvc::noinline]]
# else # else
# define G_NO_INLINE __declspec (noinline) # define G_NO_INLINE __declspec (noinline)