mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-02 07:36:17 +01:00
glib/gmacros.h: Fix build on C++ mode in Visual Studio
Later Visual Studio versions does not allow one to define known keywords, even if they are actually not known to the compiler. Avoid this issue by checking more conditions before we define inline as __inline: -We are not building under C++ mode. -We are on Visual Studio 2013 or earlier. Where both of these conditions need to hold true. https://bugzilla.gnome.org/show_bug.cgi?id=765990
This commit is contained in:
parent
217b620a7b
commit
2ca496a2e7
@ -54,16 +54,31 @@
|
||||
#endif
|
||||
|
||||
/* Every compiler that we target supports inlining, but some of them may
|
||||
* complain about it if we don't say "__inline". If we have C99, then
|
||||
* we can use "inline" directly. Otherwise, we say "__inline" to avoid
|
||||
* the warning.
|
||||
* complain about it if we don't say "__inline". If we have C99, or if
|
||||
* we are using C++, then we can use "inline" directly. Unfortunately
|
||||
* Visual Studio does not support __STDC_VERSION__, so we need to check
|
||||
* whether we are on Visual Studio 2013 or earlier to see that we need to
|
||||
* say "__inline" in C mode.
|
||||
* Otherwise, we say "__inline" to avoid the warning.
|
||||
*/
|
||||
#define G_CAN_INLINE
|
||||
#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199900)
|
||||
#undef inline
|
||||
#define inline __inline
|
||||
#ifndef __cplusplus
|
||||
# ifdef _MSC_VER
|
||||
# if (_MSC_VER < 1900)
|
||||
# define G_INLINE_DEFINE_NEEDED
|
||||
# endif
|
||||
# elif !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199900)
|
||||
# define G_INLINE_DEFINE_NEEDED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef G_INLINE_DEFINE_NEEDED
|
||||
# undef inline
|
||||
# define inline __inline
|
||||
#endif
|
||||
|
||||
#undef G_INLINE_DEFINE_NEEDED
|
||||
|
||||
/* For historical reasons we need to continue to support those who
|
||||
* define G_IMPLEMENT_INLINES to mean "don't implement this here".
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user