]> git.pond.sub.org Git - empserver/commit
Provide proper build-time assertions for NSC_SITYPE()
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 4 Jul 2015 12:53:20 +0000 (14:53 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 5 Dec 2015 11:42:40 +0000 (12:42 +0100)
commit80bf4ec34b6ead7ba9649da68e4ae47d28b58701
tree22fd04f5467254ed71dd682e9b8c979272e6309f
parentd074d29736f7c49fdd4bcfb4258b1a21f74c0adf
Provide proper build-time assertions for NSC_SITYPE()

We want to cause a diagnostic when NSC_SITYPE()'s argument isn't
implemented.  Commit aa6ad9d's solution is to have the macro expand
into 1/0 then.  Works with GCC, but Clang always warns "division by
zero is undefined".

The better, portable way to conditionally break the build is an array
type with a size that's negative when the build should fail, else
positive.  Implement that wrapped in a sizeof() to make it an
expression as macro BUILD_ASSERT_ONE(), and use it in NSC_SITYPE().

No more warnings from Clang 3.5.0.  GCC still produces its "may be
used uninitialized" false positives.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
include/misc.h
include/nsc.h