lib/sod.h: Introduce `SOD_RECKLESS' feature macro to inhibit checking.
[sod] / lib / sod.h
index 5a14ade..dd1ee03 100644 (file)
--- a/lib/sod.h
+++ b/lib/sod.h
@@ -116,6 +116,22 @@ SOD__VARARGS_MACROS_PREAMBLE
 
 #define SOD__IGNORE(var) ((void)(var))
 
+/* --- @SOD__PARANOIA@ --- *
+ *
+ * Arguments:  @cond@ = a condition to check
+ *             @conseq@ = a thing to evaluate to if the check passes
+ *             @alt@ = a thing to do if the check fails
+ *
+ * Use:                Check to make sure something is good at runtime, unless
+ *             disabled.
+ */
+
+#if SOD_RECKLESS
+#  define SOD__PARANOIA(cond, conseq, alt) (conseq)
+#else
+#  define SOD__PARANOIA(cond, conseq, alt) ((cond) ? (conseq) : (alt))
+#endif
+
 /* --- @SOD__CAR@ --- *
  *
  * Arguments:  @...@ = a nonempty list of arguments