diff options
author | Lukasz Skalski <l.skalski@partner.samsung.com> | 2013-11-22 14:44:45 +0100 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2013-11-22 14:44:45 +0100 |
commit | ab9cbe342e5550e46731411a7166d3d9f7808adf (patch) | |
tree | 77359657ab93d275edceda12742e2ca356b0df9b /src/shared/macro.h | |
parent | 128c3c5881e5708b3f15517ee24dd8c0a1c6307e (diff) |
macro: fix problem with __LINE__ macro expansion
David:
I already applied a fix for that, but this patch definitely looks nicer. I
changed CONCATENATE_HELPER() -> XCONCATENATE() similar to XSTRINGIFY and
added the UNIQUE() helper.
Diffstat (limited to 'src/shared/macro.h')
-rw-r--r-- | src/shared/macro.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/shared/macro.h b/src/shared/macro.h index aadb1959c0..d64e3c3d44 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -53,6 +53,11 @@ #define XSTRINGIFY(x) #x #define STRINGIFY(x) XSTRINGIFY(x) +#define XCONCATENATE(x, y) x ## y +#define CONCATENATE(x, y) XCONCATENATE(x, y) + +#define UNIQUE(prefix) CONCATENATE(prefix, __LINE__) + /* Rounds up */ #define ALIGN4(l) (((l) + 3) & ~3) @@ -145,9 +150,7 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { #if defined(static_assert) #define assert_cc(expr) static_assert(expr, #expr) #else -#define assert___cc(expr, line) struct _assert_struct_ ## line { char x[(expr) ? 0 : -1]; } -#define assert__cc(expr, line) assert___cc((expr), line) -#define assert_cc(expr) assert__cc((expr), __LINE__) +#define assert_cc(expr) struct UNIQUE(_assert_struct_) { char x[(expr) ? 0 : -1]; }; #endif #define assert_return(expr, r) \ |