summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-01-04 16:33:52 +0100
committerTyge Løvset <[email protected]>2023-01-04 16:33:52 +0100
commit41c8dfe25d9ef785c3b8a9f00f042a61669af7e6 (patch)
tree6a996716e1421533b04bd5c7d889298fec531c35 /include
parentbb754d1e0e728c6b0f41efff16e512af04a0b3b8 (diff)
downloadSTC-modified-41c8dfe25d9ef785c3b8a9f00f042a61669af7e6.tar.gz
STC-modified-41c8dfe25d9ef785c3b8a9f00f042a61669af7e6.zip
Improved a few examples.
Diffstat (limited to 'include')
-rw-r--r--include/stc/ccommon.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 9cdbc9e5..9ff83be5 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -60,23 +60,23 @@
#define _c_RSEQ_N 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
#define _c_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, \
_14, _15, _16, N, ...) N
-
-#define c_STATIC_ASSERT(cond, msg) \
- ((void)sizeof(int[(cond) ? 1 : -1]))
+/* Cast result to (void) to depress -Wall warning: */
+#define c_STATIC_ASSERT(cond, ...) \
+ ((int)(0*sizeof(int[(cond) ? 1 : -1])))
#define c_CONTAINER_OF(p, T, m) \
((T*)((char*)(p) + 0*sizeof((p) == &((T*)0)->m) - offsetof(T, m)))
-#ifndef __cplusplus
- #define c_ALLOC(T) c_MALLOC(sizeof(T))
- #define c_ALLOC_N(T, n) c_MALLOC(sizeof(T)*(n))
- #define c_NEW(T, ...) ((T*)memcpy(c_ALLOC(T), (T[]){__VA_ARGS__}, sizeof(T)))
- #define c_INIT(T) (T)
-#else
+#ifdef __cplusplus
#include <new>
#define c_ALLOC(T) static_cast<T*>(c_MALLOC(sizeof(T)))
#define c_ALLOC_N(T, n) static_cast<T*>(c_MALLOC(sizeof(T)*(n)))
#define c_NEW(T, ...) new (c_ALLOC(T)) T(__VA_ARGS__)
#define c_INIT(T) T
+#else
+ #define c_ALLOC(T) ((T*)c_MALLOC(sizeof(T)))
+ #define c_ALLOC_N(T, n) ((T*)c_MALLOC(sizeof(T)*(n)))
+ #define c_NEW(T, ...) ((T*)memcpy(c_ALLOC(T), (T[]){__VA_ARGS__}, sizeof(T)))
+ #define c_INIT(T) (T)
#endif
#ifndef c_MALLOC
#define c_MALLOC(sz) malloc(sz)