|
@@ -267,6 +267,20 @@ extern "C" {
|
|
|
# define UA_BINARY_OVERLAYABLE_FLOAT 0
|
|
|
#endif
|
|
|
|
|
|
+/**
|
|
|
+ * Static Assert
|
|
|
+ * ^^^^^^^^^^^^^
|
|
|
+ *
|
|
|
+ * Outputs an error message at compile time if the assert fails.
|
|
|
+ * Example usage:
|
|
|
+ * UA_STATIC_ASSERT(sizeof(long)==7, use_another_compiler_luke) *
|
|
|
+ * See: https://stackoverflow.com/a/4815532/869402 */
|
|
|
+#define UA_CTASTR2(pre,post) pre ## post
|
|
|
+#define UA_CTASTR(pre,post) UA_CTASTR2(pre,post)
|
|
|
+#define UA_STATIC_ASSERT(cond,msg) \
|
|
|
+ typedef struct { int UA_CTASTR(static_assertion_failed_,msg) : !!(cond); } \
|
|
|
+ UA_CTASTR(static_assertion_failed_,__COUNTER__)
|
|
|
+
|
|
|
#ifdef __cplusplus
|
|
|
} // extern "C"
|
|
|
#endif
|