]> git.ipfire.org Git - thirdparty/systemd.git/commit
macro: add CONST_MAX() macro
authorDavid Herrmann <dh.herrmann@gmail.com>
Fri, 15 Aug 2014 14:54:52 +0000 (16:54 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Fri, 15 Aug 2014 14:59:09 +0000 (16:59 +0200)
commit7242d7420b04132f93f1426ec713f9b09bdeba54
tree79937cb4843d701f1f7c6fdb6b954a9c9a720925
parentfdcba430aeae442ab0ea12a08d96cfc3d13f57ef
macro: add CONST_MAX() macro

The CONST_MAX() macro is similar to MAX(), but verifies that both
arguments have the same type and are constant expressions. Furthermore,
the result of CONST_MAX() is again a constant-expression.

CONST_MAX() avoids any statement-expressions and other non-trivial
expression-types. This avoids rather arbitrary restrictions in both GCC
and LLVM, which both either fail with statement-expressions inside
type-declarations or statement-expressions inside static-const
initializations.

If anybody knows how to circumvent this, please feel free to unify
CONST_MAX() and MAX().
src/shared/macro.h
src/test/test-util.c