-void check (bool, const char *, ...) PRINTF_FORMAT (2, 3);
+
+/* Takes an expression to test for SUCCESS and a message, which
+ may include printf-style arguments. Logs the message, then
+ tests the expression. If it is zero, indicating failure,
+ emits the message as a failure.
+
+ Somewhat tricky to use:
+
+ - SUCCESS must not have side effects that affect the
+ message, because that will cause the original message and
+ the failure message to differ.
+
+ - The message must not have side effects of its own, because
+ it will be printed twice on failure, or zero times on
+ success if quiet is set. */
+#define CHECK(SUCCESS, ...) \
+ do \
+ { \
+ msg (__VA_ARGS__); \
+ if (!(SUCCESS)) \
+ fail (__VA_ARGS__); \
+ } \
+ while (0)