mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
(VERIFY): Rewrite to use string-concatenation
and __LINE__ so as not to require a struct name parameter. (GL_CONCAT, GL_CONCAT2, GL_LINE_CONCAT): Define helper macros.
This commit is contained in:
1 parent
e4d87dd573
commit
87f543aea5
1 file changed
+5
-1
+5
-1
@@ -812,8 +812,12 @@ ptr_align (void const *ptr, size_t alignment)
|
||||
return (void *) (p1 - (size_t) p1 % alignment);
|
||||
}
|
||||
|
||||
#define GL_CONCAT(x,y) x##y
|
||||
#define GL_CONCAT2(x,y) GL_CONCAT(x,y)
|
||||
#define GL_LINE_CONCAT(x) GL_CONCAT2(x, __LINE__)
|
||||
/* Verify a requirement at compile-time (unlike assert, which is runtime). */
|
||||
#define VERIFY(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
|
||||
#define VERIFY(assertion) \
|
||||
struct GL_LINE_CONCAT(compile_time_assert) { char a[(assertion) ? 1 : -1]; }
|
||||
|
||||
/* Like the above, but use an expression rather than a struct declaration.
|
||||
This macro may be used in some contexts where the other may not. */
|
||||
|
||||
Reference in new issue
Block a user