• Konstantin Khlebnikov's avatar
    bug: introduce BUILD_BUG_ON_INVALID() macro · baf05aa9
    Konstantin Khlebnikov authored
    Sometimes we want to check some expressions correctness at compile time.
    "(void)(e);" or "if (e);" can be dangerous if the expression has
    side-effects, and gcc sometimes generates a lot of code, even if the
    expression has no effect.
    This patch introduces macro BUILD_BUG_ON_INVALID() for such checks, it
    forces a compilation error if expression is invalid without any extra
    [Cast to "long" required because sizeof does not work for bit-fields.]
    Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@openvz.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Geert Uytterhoeven <geert@linux-m68k.org>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Cong Wang <xiyou.wangcong@gmail.com>
    Cc: Hugh Dickins <hughd@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
bug.h 3.16 KB