One macro based on GCC visibility functions was already defined,
__exported. However, it was marked as available for all GCC versions
when it fact it was introduced with gcc 4.0.
There was no macro for hidden visibility attributes, so the macros
__dso_hidden and __dso_public were borrowed from NetBSD. __dso_public
is an alias for __exported. The definition for all three macros were
made on the condition that the gcc version used is 4.0 or later.
#ifndef _SYS_CDEFS_H_
#define _SYS_CDEFS_H_
-#if defined(__GNUC__)
-#define __exported __attribute__((__visibility__("default")))
-#else
-#define __exported
-#endif
-
#if defined(__cplusplus)
#define __BEGIN_DECLS extern "C" {
#define __END_DECLS }
#define __ARRAY_ZERO
#endif
+#if __GNUC_PREREQ__(4, 0)
+#define __exported __attribute__((__visibility__("default")))
+#define __dso_public __attribute__((__visibility__("default")))
+#define __dso_hidden __attribute__((__visibility__("hidden")))
+#else
+#define __exported
+#define __dso_public
+#define __dso_hidden
+#endif
+
/*
* A convenient constructor macro, GCC 4.3.0 added priority support to
* constructors, provide a compatible interface for both.