aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-01-02 17:22:55 -0500
committerDavid Robillard <d@drobilla.net>2023-01-02 17:22:55 -0500
commit9f85fadca801033e8873e918a52e80fd12426734 (patch)
treec332f715ee517dc2a740fbad7fce3f8c3b32b2ee
parentbc50edc0c5bfc4f42289150c8b9f3556cb6bff5c (diff)
downloadpugl-9f85fadca801033e8873e918a52e80fd12426734.tar.gz
pugl-9f85fadca801033e8873e918a52e80fd12426734.tar.bz2
pugl-9f85fadca801033e8873e918a52e80fd12426734.zip
Move attributes to a separate header
-rw-r--r--include/pugl/attributes.h59
-rw-r--r--include/pugl/pugl.h48
-rw-r--r--src/internal.h1
-rw-r--r--src/x11.h1
4 files changed, 63 insertions, 46 deletions
diff --git a/include/pugl/attributes.h b/include/pugl/attributes.h
new file mode 100644
index 0000000..75322ee
--- /dev/null
+++ b/include/pugl/attributes.h
@@ -0,0 +1,59 @@
+// Copyright 2012-2022 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#ifndef PUGL_ATTRIBUTES_H
+#define PUGL_ATTRIBUTES_H
+
+// Public declaration scope
+#ifdef __cplusplus
+# define PUGL_BEGIN_DECLS extern "C" {
+# define PUGL_END_DECLS }
+#else
+# define PUGL_BEGIN_DECLS ///< Begin public API definitions
+# define PUGL_END_DECLS ///< End public API definitions
+#endif
+
+// Symbol exposed in the public API
+#ifndef PUGL_API
+# if defined(_WIN32) && !defined(PUGL_STATIC) && defined(PUGL_INTERNAL)
+# define PUGL_API __declspec(dllexport)
+# elif defined(_WIN32) && !defined(PUGL_STATIC)
+# define PUGL_API __declspec(dllimport)
+# elif defined(__GNUC__)
+# define PUGL_API __attribute__((visibility("default")))
+# else
+# define PUGL_API
+# endif
+#endif
+
+// Deprecated API
+#ifndef PUGL_DISABLE_DEPRECATED
+# if defined(__clang__)
+# define PUGL_DEPRECATED_BY(rep) __attribute__((deprecated("", rep)))
+# elif defined(__GNUC__)
+# define PUGL_DEPRECATED_BY(rep) __attribute__((deprecated("Use " rep)))
+# else
+# define PUGL_DEPRECATED_BY(rep)
+# endif
+#endif
+
+// GCC function attributes
+#if defined(__GNUC__)
+# define PUGL_CONST_FUNC __attribute__((const))
+# define PUGL_MALLOC_FUNC __attribute__((malloc))
+#else
+# define PUGL_CONST_FUNC ///< Only reads its parameters
+# define PUGL_MALLOC_FUNC ///< Allocates memory
+#endif
+
+/// A const function in the public API that only reads parameters
+#define PUGL_CONST_API \
+ PUGL_API \
+ PUGL_CONST_FUNC
+
+/// A malloc function in the public API that returns allocated memory
+#define PUGL_MALLOC_API \
+ PUGL_API \
+ PUGL_MALLOC_FUNC
+
+#endif // PUGL_ATTRIBUTES_H
diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h
index 62284e6..981d76d 100644
--- a/include/pugl/pugl.h
+++ b/include/pugl/pugl.h
@@ -4,6 +4,8 @@
#ifndef PUGL_PUGL_H
#define PUGL_PUGL_H
+#include "pugl/attributes.h"
+
#include <stddef.h>
#include <stdint.h>
@@ -11,52 +13,6 @@
# include <stdbool.h>
#endif
-#ifndef PUGL_API
-# if defined(_WIN32) && !defined(PUGL_STATIC) && defined(PUGL_INTERNAL)
-# define PUGL_API __declspec(dllexport)
-# elif defined(_WIN32) && !defined(PUGL_STATIC)
-# define PUGL_API __declspec(dllimport)
-# elif defined(__GNUC__)
-# define PUGL_API __attribute__((visibility("default")))
-# else
-# define PUGL_API
-# endif
-#endif
-
-#ifndef PUGL_DISABLE_DEPRECATED
-# if defined(__clang__)
-# define PUGL_DEPRECATED_BY(rep) __attribute__((deprecated("", rep)))
-# elif defined(__GNUC__)
-# define PUGL_DEPRECATED_BY(rep) __attribute__((deprecated("Use " rep)))
-# else
-# define PUGL_DEPRECATED_BY(rep)
-# endif
-#endif
-
-#if defined(__GNUC__)
-# define PUGL_CONST_FUNC __attribute__((const))
-# define PUGL_MALLOC_FUNC __attribute__((malloc))
-#else
-# define PUGL_CONST_FUNC
-# define PUGL_MALLOC_FUNC
-#endif
-
-#define PUGL_CONST_API \
- PUGL_API \
- PUGL_CONST_FUNC
-
-#define PUGL_MALLOC_API \
- PUGL_API \
- PUGL_MALLOC_FUNC
-
-#ifdef __cplusplus
-# define PUGL_BEGIN_DECLS extern "C" {
-# define PUGL_END_DECLS }
-#else
-# define PUGL_BEGIN_DECLS
-# define PUGL_END_DECLS
-#endif
-
PUGL_BEGIN_DECLS
/**
diff --git a/src/internal.h b/src/internal.h
index 066dc7e..0fb5f65 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -9,6 +9,7 @@
#include "attributes.h"
#include "types.h"
+#include "pugl/attributes.h"
#include "pugl/pugl.h"
#include <stddef.h>
diff --git a/src/x11.h b/src/x11.h
index 27cfb73..a34d698 100644
--- a/src/x11.h
+++ b/src/x11.h
@@ -7,6 +7,7 @@
#include "attributes.h"
#include "types.h"
+#include "pugl/attributes.h"
#include "pugl/pugl.h"
#include <X11/X.h>