summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension/compiler.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-06-12 13:45:06 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-06-12 13:45:06 -0400
commit0fec83ebc89bd6b86f772d942b7c39b13f773d3a (patch)
treef2d10a7fe784773b4722843ce3f2bbe1c8e0db62 /libdimension/dimension/compiler.h
parentbb976e3a5cc01abecf6729eb511f75fb21c6d2c4 (diff)
downloaddimension-0fec83ebc89bd6b86f772d942b7c39b13f773d3a.tar.xz
Add a C89 compliance test for the headers.
Technically we still require a couple things from C99 like "bool", but it works with -std=c89 under gcc.
Diffstat (limited to 'libdimension/dimension/compiler.h')
-rw-r--r--libdimension/dimension/compiler.h33
1 files changed, 28 insertions, 5 deletions
diff --git a/libdimension/dimension/compiler.h b/libdimension/dimension/compiler.h
index 952200b..3d392b5 100644
--- a/libdimension/dimension/compiler.h
+++ b/libdimension/dimension/compiler.h
@@ -30,23 +30,46 @@
*/
#ifndef DMNSN_INLINE
#ifdef __cplusplus
- // C++ inline semantics
+ /* C++ inline semantics */
#define DMNSN_INLINE inline
#elif __STDC_VERSION__ >= 199901L
- // C99 inline semantics
+ /* C99 inline semantics */
#define DMNSN_INLINE inline
#elif defined(__GNUC__)
- // GCC inline semantics
+ /* GCC inline semantics */
#define DMNSN_INLINE __extension__ extern __inline__
#else
- // Unknown C - mark functions static and hope the compiler is smart enough
- // to inline them
+ /* Unknown C - mark functions static and hope the compiler is smart enough
+ to inline them */
#define DMNSN_INLINE static
#endif
#endif
+/**
+ * @internal
+ * @def DMNSN_FUNC
+ * @brief Expands to the name of the current function
+ */
+#ifdef __GNUC__
+ #define DMNSN_FUNC __PRETTY_FUNCTION__
+#elif __STDC_VERSION__ >= 199901L
+ #define DMNSN_FUNC __func__
+#else
+ #define DMNSN_FUNC "<unknown function>"
+#endif
+
+/**
+ * @internal
+ * An unreachable statement.
+ */
#ifdef __GNUC__
#define DMNSN_UNREACHABLE() __builtin_unreachable()
#else
#define DMNSN_UNREACHABLE() ((void)0)
#endif
+
+/**
+ * @internal
+ * Whether C99 features are supported.
+ */
+#define DMNSN_C99 (__STDC_VERSION__ >= 199901L || __cplusplus >= 201103L)