summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-10-20 21:34:24 -0400
committerDavid Robillard <d@drobilla.net>2022-10-21 12:45:39 -0400
commit03554253ae5dbdd12d619db81864b38d5e300171 (patch)
treeca08314421d4f80e46317eb2c56fd88cf9f3984f
parent2ff624eae24742faf17889f858dbdaa6d4a064ea (diff)
downloadzix-03554253ae5dbdd12d619db81864b38d5e300171.tar.gz
zix-03554253ae5dbdd12d619db81864b38d5e300171.tar.bz2
zix-03554253ae5dbdd12d619db81864b38d5e300171.zip
Factor out public declaration scope markers
-rw-r--r--.clang-format2
-rw-r--r--include/zix/allocator.h8
-rw-r--r--include/zix/attributes.h12
-rw-r--r--include/zix/btree.h8
-rw-r--r--include/zix/digest.h8
-rw-r--r--include/zix/function_types.h8
-rw-r--r--include/zix/hash.h8
-rw-r--r--include/zix/ring.h8
-rw-r--r--include/zix/sem.h8
-rw-r--r--include/zix/status.h8
-rw-r--r--include/zix/thread.h8
-rw-r--r--include/zix/tree.h8
12 files changed, 34 insertions, 60 deletions
diff --git a/.clang-format b/.clang-format
index 90caefc..d5bb2b7 100644
--- a/.clang-format
+++ b/.clang-format
@@ -20,8 +20,10 @@ KeepEmptyLinesAtTheStartOfBlocks: false
SpacesInContainerLiterals: false
StatementMacros:
- ZIX_API
+ - ZIX_BEGIN_DECLS
- ZIX_CONST_API
- ZIX_CONST_API
+ - ZIX_END_DECLS
- ZIX_MALLOC_API
- ZIX_PURE_API
- ZIX_THREAD_FUNC
diff --git a/include/zix/allocator.h b/include/zix/allocator.h
index 7a4f5ee..26db6d3 100644
--- a/include/zix/allocator.h
+++ b/include/zix/allocator.h
@@ -8,9 +8,7 @@
#include <stddef.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ZIX_BEGIN_DECLS
/**
@defgroup zix_allocator Allocator
@@ -177,8 +175,6 @@ zix_aligned_free(ZixAllocator* const ZIX_NULLABLE allocator,
@}
*/
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+ZIX_END_DECLS
#endif /* ZIX_ALLOCATOR_H */
diff --git a/include/zix/attributes.h b/include/zix/attributes.h
index 7c352d2..ea18760 100644
--- a/include/zix/attributes.h
+++ b/include/zix/attributes.h
@@ -10,6 +10,15 @@
@{
*/
+// Public declaration scope
+#ifdef __cplusplus
+# define ZIX_BEGIN_DECLS extern "C" {
+# define ZIX_END_DECLS }
+#else
+# define ZIX_BEGIN_DECLS
+# define ZIX_END_DECLS
+#endif
+
// ZIX_API must be used to decorate things in the public API
#ifndef ZIX_API
# if defined(_WIN32) && !defined(ZIX_STATIC) && defined(ZIX_INTERNAL)
@@ -34,14 +43,17 @@
# define ZIX_MALLOC_FUNC
#endif
+/// A pure function in the public API that only reads memory
#define ZIX_PURE_API \
ZIX_API \
ZIX_PURE_FUNC
+/// A const function in the public API that is pure and only reads parameters
#define ZIX_CONST_API \
ZIX_API \
ZIX_CONST_FUNC
+/// A malloc function in the public API that returns allocated memory
#define ZIX_MALLOC_API \
ZIX_API \
ZIX_MALLOC_FUNC
diff --git a/include/zix/btree.h b/include/zix/btree.h
index 33f47d1..0658be8 100644
--- a/include/zix/btree.h
+++ b/include/zix/btree.h
@@ -13,9 +13,7 @@
#include <stddef.h>
#include <stdint.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ZIX_BEGIN_DECLS
/**
@defgroup zix_btree BTree
@@ -213,8 +211,6 @@ zix_btree_iter_next(ZixBTreeIter iter);
@}
*/
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+ZIX_END_DECLS
#endif /* ZIX_BTREE_H */
diff --git a/include/zix/digest.h b/include/zix/digest.h
index 5a0eb16..4c15444 100644
--- a/include/zix/digest.h
+++ b/include/zix/digest.h
@@ -9,9 +9,7 @@
#include <stddef.h>
#include <stdint.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ZIX_BEGIN_DECLS
/**
@defgroup zix_digest Digest
@@ -94,8 +92,6 @@ zix_digest_aligned(size_t seed, const void* ZIX_NONNULL buf, size_t len);
@}
*/
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+ZIX_END_DECLS
#endif /* ZIX_DIGEST_H */
diff --git a/include/zix/function_types.h b/include/zix/function_types.h
index 8822847..e2a8958 100644
--- a/include/zix/function_types.h
+++ b/include/zix/function_types.h
@@ -8,9 +8,7 @@
#include <stdbool.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ZIX_BEGIN_DECLS
/**
@defgroup zix_function_types Function Types
@@ -30,8 +28,6 @@ typedef void (*ZixDestroyFunc)(void* ptr, const void* user_data);
@}
*/
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+ZIX_END_DECLS
#endif /* ZIX_FUNCTION_TYPES_H */
diff --git a/include/zix/hash.h b/include/zix/hash.h
index 397e055..d362389 100644
--- a/include/zix/hash.h
+++ b/include/zix/hash.h
@@ -11,9 +11,7 @@
#include <stdbool.h>
#include <stddef.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ZIX_BEGIN_DECLS
/**
@defgroup zix_hash Hash
@@ -321,8 +319,6 @@ zix_hash_find_record(const ZixHash* ZIX_NONNULL hash,
@}
*/
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+ZIX_END_DECLS
#endif /* ZIX_HASH_H */
diff --git a/include/zix/ring.h b/include/zix/ring.h
index 66662b7..ec255a4 100644
--- a/include/zix/ring.h
+++ b/include/zix/ring.h
@@ -10,9 +10,7 @@
#include <stdint.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ZIX_BEGIN_DECLS
/**
@defgroup zix_ring Ring
@@ -208,8 +206,6 @@ zix_ring_commit_write(ZixRing* ZIX_NONNULL ring,
@}
*/
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+ZIX_END_DECLS
#endif /* ZIX_RING_H */
diff --git a/include/zix/sem.h b/include/zix/sem.h
index 3777497..b22dfdd 100644
--- a/include/zix/sem.h
+++ b/include/zix/sem.h
@@ -15,9 +15,7 @@
# include <semaphore.h>
#endif
-#ifdef __cplusplus
-extern "C" {
-#endif
+ZIX_BEGIN_DECLS
#include <stdint.h>
@@ -147,8 +145,6 @@ struct ZixSemImpl {
@}
*/
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+ZIX_END_DECLS
#endif /* ZIX_SEM_H */
diff --git a/include/zix/status.h b/include/zix/status.h
index fcd45fb..906b812 100644
--- a/include/zix/status.h
+++ b/include/zix/status.h
@@ -6,9 +6,7 @@
#include "zix/attributes.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+ZIX_BEGIN_DECLS
/**
@defgroup zix Zix C API
@@ -43,8 +41,6 @@ zix_strerror(ZixStatus status);
@}
*/
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+ZIX_END_DECLS
#endif /* ZIX_STATUS_H */
diff --git a/include/zix/thread.h b/include/zix/thread.h
index 14c525d..3ba4702 100644
--- a/include/zix/thread.h
+++ b/include/zix/thread.h
@@ -15,9 +15,7 @@
#include <stddef.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ZIX_BEGIN_DECLS
/**
@defgroup zix_thread Thread
@@ -78,8 +76,6 @@ zix_thread_join(ZixThread thread);
@}
*/
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+ZIX_END_DECLS
#endif /* ZIX_THREAD_H */
diff --git a/include/zix/tree.h b/include/zix/tree.h
index 7b77a7c..919cba9 100644
--- a/include/zix/tree.h
+++ b/include/zix/tree.h
@@ -12,9 +12,7 @@
#include <stdbool.h>
#include <stddef.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ZIX_BEGIN_DECLS
/**
@defgroup zix_tree Tree
@@ -120,8 +118,6 @@ zix_tree_iter_prev(ZixTreeIter* ZIX_NULLABLE i);
@}
*/
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+ZIX_END_DECLS
#endif /* ZIX_TREE_H */