Add a new _GLIB_EXTERN macro for "extern"

This macro simply evaluates the "extern" unless it has been explicitly
defined to something else.

All of the version macros (including the unversioned deprecation markers
and GLIB_AVAILABLE_IN_ALL) now include _GLIB_EXTERN as part of their
definition.

G_INLINE has also been modified to use _GLIB_EXTERN where appropriate.

This macro should never be used outside of the gmacros.h/gversonmacros.h
headers.

The effect of this patch is that "extern" has now been added to all
functions declared in installed headers.  Strictly speaking, this is
something we should have had all along...

GLIB_VAR and GOBJECT_VAR have also been modified to use _GLIB_EXTERN on
non-Windows, instead of "extern" which they were using before.  The
eventual goal is to use the normal version/deprecation macros on
exported variables and drop GLIB_VAR but we need to see how this will
work on Windows before we go ahead with that.

https://bugzilla.gnome.org/show_bug.cgi?id=688681
This commit is contained in:
Ryan Lortie
2012-12-06 13:37:45 -05:00
parent ba1bdd0708
commit b91c476827
5 changed files with 33 additions and 29 deletions

View File

@@ -324,6 +324,10 @@
#define G_UNAVAILABLE(maj,min)
#endif
#ifndef _GLIB_EXTERN
#define _GLIB_EXTERN extern
#endif
/* These macros are used to mark deprecated functions in GLib headers,
* and thus have to be exposed in installed headers. But please
* do *not* use them in other projects. Instead, use G_DEPRECATED
@@ -331,13 +335,13 @@
*/
#ifdef GLIB_DISABLE_DEPRECATION_WARNINGS
#define GLIB_DEPRECATED
#define GLIB_DEPRECATED_FOR(f)
#define GLIB_UNAVAILABLE(maj,min)
#define GLIB_DEPRECATED _GLIB_EXTERN
#define GLIB_DEPRECATED_FOR(f) _GLIB_EXTERN
#define GLIB_UNAVAILABLE(maj,min) _GLIB_EXTERN
#else
#define GLIB_DEPRECATED G_DEPRECATED
#define GLIB_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f)
#define GLIB_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min)
#define GLIB_DEPRECATED G_DEPRECATED _GLIB_EXTERN
#define GLIB_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _GLIB_EXTERN
#define GLIB_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _GLIB_EXTERN
#endif
#endif /* __G_MACROS_H__ */

View File

@@ -477,7 +477,7 @@ G_END_DECLS
# endif /* !GLIB_COMPILATION */
# endif /* !GLIB_STATIC_COMPILATION */
# else /* !G_PLATFORM_WIN32 */
# define GLIB_VAR extern
# define GLIB_VAR _GLIB_EXTERN
# endif /* !G_PLATFORM_WIN32 */
#endif /* GLIB_VAR */

View File

@@ -74,14 +74,14 @@ G_BEGIN_DECLS
# endif
#endif
#ifdef G_IMPLEMENT_INLINES
# define G_INLINE_FUNC
# define G_INLINE_FUNC _GLIB_EXTERN
# undef G_CAN_INLINE
#elif defined (__GNUC__)
# define G_INLINE_FUNC static __inline __attribute__ ((unused))
#elif defined (G_CAN_INLINE)
# define G_INLINE_FUNC static inline
#else /* can't inline */
# define G_INLINE_FUNC
# define G_INLINE_FUNC _GLIB_EXTERN
#endif /* !G_INLINE_FUNC */
GLIB_AVAILABLE_IN_ALL

View File

@@ -184,7 +184,7 @@
* do *not* use them in other projects. Instead, use G_DEPRECATED
* or define your own wrappers around it.
*/
#define GLIB_AVAILABLE_IN_ALL
#define GLIB_AVAILABLE_IN_ALL _GLIB_EXTERN
/* XXX: Every new stable minor release should add a set of macros here */
@@ -192,84 +192,84 @@
# define GLIB_DEPRECATED_IN_2_26 GLIB_DEPRECATED
# define GLIB_DEPRECATED_IN_2_26_FOR(f) GLIB_DEPRECATED_FOR(f)
#else
# define GLIB_DEPRECATED_IN_2_26
# define GLIB_DEPRECATED_IN_2_26_FOR(f)
# define GLIB_DEPRECATED_IN_2_26 _GLIB_EXTERN
# define GLIB_DEPRECATED_IN_2_26_FOR(f) _GLIB_EXTERN
#endif
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26
# define GLIB_AVAILABLE_IN_2_26 GLIB_UNAVAILABLE(2, 26)
#else
# define GLIB_AVAILABLE_IN_2_26
# define GLIB_AVAILABLE_IN_2_26 _GLIB_EXTERN
#endif
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28
# define GLIB_DEPRECATED_IN_2_28 GLIB_DEPRECATED
# define GLIB_DEPRECATED_IN_2_28_FOR(f) GLIB_DEPRECATED_FOR(f)
#else
# define GLIB_DEPRECATED_IN_2_28
# define GLIB_DEPRECATED_IN_2_28_FOR(f)
# define GLIB_DEPRECATED_IN_2_28 _GLIB_EXTERN
# define GLIB_DEPRECATED_IN_2_28_FOR(f) _GLIB_EXTERN
#endif
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28
# define GLIB_AVAILABLE_IN_2_28 GLIB_UNAVAILABLE(2, 28)
#else
# define GLIB_AVAILABLE_IN_2_28
# define GLIB_AVAILABLE_IN_2_28 _GLIB_EXTERN
#endif
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30
# define GLIB_DEPRECATED_IN_2_30 GLIB_DEPRECATED
# define GLIB_DEPRECATED_IN_2_30_FOR(f) GLIB_DEPRECATED_FOR(f)
#else
# define GLIB_DEPRECATED_IN_2_30
# define GLIB_DEPRECATED_IN_2_30_FOR(f)
# define GLIB_DEPRECATED_IN_2_30 _GLIB_EXTERN
# define GLIB_DEPRECATED_IN_2_30_FOR(f) _GLIB_EXTERN
#endif
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30
# define GLIB_AVAILABLE_IN_2_30 GLIB_UNAVAILABLE(2, 30)
#else
# define GLIB_AVAILABLE_IN_2_30
# define GLIB_AVAILABLE_IN_2_30 _GLIB_EXTERN
#endif
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32
# define GLIB_DEPRECATED_IN_2_32 GLIB_DEPRECATED
# define GLIB_DEPRECATED_IN_2_32_FOR(f) GLIB_DEPRECATED_FOR(f)
#else
# define GLIB_DEPRECATED_IN_2_32
# define GLIB_DEPRECATED_IN_2_32_FOR(f)
# define GLIB_DEPRECATED_IN_2_32 _GLIB_EXTERN
# define GLIB_DEPRECATED_IN_2_32_FOR(f) _GLIB_EXTERN
#endif
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32
# define GLIB_AVAILABLE_IN_2_32 GLIB_UNAVAILABLE(2, 32)
#else
# define GLIB_AVAILABLE_IN_2_32
# define GLIB_AVAILABLE_IN_2_32 _GLIB_EXTERN
#endif
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34
# define GLIB_DEPRECATED_IN_2_34 GLIB_DEPRECATED
# define GLIB_DEPRECATED_IN_2_34_FOR(f) GLIB_DEPRECATED_FOR(f)
#else
# define GLIB_DEPRECATED_IN_2_34
# define GLIB_DEPRECATED_IN_2_34_FOR(f)
# define GLIB_DEPRECATED_IN_2_34 _GLIB_EXTERN
# define GLIB_DEPRECATED_IN_2_34_FOR(f) _GLIB_EXTERN
#endif
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34
# define GLIB_AVAILABLE_IN_2_34 GLIB_UNAVAILABLE(2, 34)
#else
# define GLIB_AVAILABLE_IN_2_34
# define GLIB_AVAILABLE_IN_2_34 _GLIB_EXTERN
#endif
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_36
# define GLIB_DEPRECATED_IN_2_36 GLIB_DEPRECATED
# define GLIB_DEPRECATED_IN_2_36_FOR(f) GLIB_DEPRECATED_FOR(f)
#else
# define GLIB_DEPRECATED_IN_2_36
# define GLIB_DEPRECATED_IN_2_36_FOR(f)
# define GLIB_DEPRECATED_IN_2_36 _GLIB_EXTERN
# define GLIB_DEPRECATED_IN_2_36_FOR(f) _GLIB_EXTERN
#endif
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_36
# define GLIB_AVAILABLE_IN_2_36 GLIB_UNAVAILABLE(2, 36)
#else
# define GLIB_AVAILABLE_IN_2_36
# define GLIB_AVAILABLE_IN_2_36 _GLIB_EXTERN
#endif
#endif /* __G_VERSION_MACROS_H__ */

View File

@@ -1155,7 +1155,7 @@ GParamSpec* g_param_spec_variant (const gchar *name,
# endif /* !GOBJECT_COMPILATION */
# endif /* !GOBJECT_STATIC_COMPILATION */
# else /* !G_PLATFORM_WIN32 */
# define GOBJECT_VAR extern
# define GOBJECT_VAR _GLIB_EXTERN
# endif /* !G_PLATFORM_WIN32 */
#endif /* GOBJECT_VAR */