summaryrefslogtreecommitdiff
path: root/ucoolib
diff options
context:
space:
mode:
authorNicolas Schodet2012-12-13 19:43:48 +0100
committerNicolas Schodet2019-10-06 23:29:59 +0200
commit88981189707bf102d61b6fd3e0f8eac8560cf533 (patch)
treed99ceafede5accaf4c6ba785ab9bfdcb7be1c08d /ucoolib
parentb47365e3003b1d8ff4ec05d3e22cdf0c241864ad (diff)
ucoolib: add lengthof, to measure an array
Diffstat (limited to 'ucoolib')
-rw-r--r--ucoolib/common.hh3
1 files changed, 3 insertions, 0 deletions
diff --git a/ucoolib/common.hh b/ucoolib/common.hh
index 5be6227..1f6d75a 100644
--- a/ucoolib/common.hh
+++ b/ucoolib/common.hh
@@ -72,4 +72,7 @@ assert_perror (bool condition)
} // namespace ucoo
+/// Get array length at compile time, must be a macro until c++11.
+#define lengthof(array) (sizeof (array) / sizeof((array)[0]))
+
#endif // ucoolib_common_h