]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blobdiff - rpp/include/base.h
Uncrustify
[pes-rpp/rpp-lib.git] / rpp / include / base.h
index 33a1d05b6dfaa38c64da90d16534ccb6eaaa78bd..749b2cd506e716cbbbc9077739b24272f5e6b454 100644 (file)
@@ -3,7 +3,7 @@
  *
  * @file base.h
  *
- * @copyright Copyright (C) 2013 Czech Technical University in Prague
+ * @copyright Copyright (C) 2013, 2015 Czech Technical University in Prague
  *
  * @author Carlos Jenkins <carlos@jenkins.co.cr>
  */
@@ -15,6 +15,7 @@
 #include "types.h"
 #include "binary.h"
 #include "os/os.h"
+#include <assert.h>
 
 // General IO directives
 /**
 #  define D(x)
 #endif
 
+/** Calculates the number of elements in an array */
+#define ARRAY_SIZE(x) (sizeof(x)/sizeof(*(x)))
+
+#if defined(static_assert)
+/** Static assertion as available in C11 standard */
+#define STATIC_ASSERT(COND,MSG) static_assert(COND, #MSG)
+#else
+/** Static assertion - non-C11 fall-back */
+#define STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(COND) ? 1 : -1]
+#endif
+
 #endif /* __BASE_H */