src/cx/common.h

changeset 945
84a5fab8a47c
parent 934
a43ed636d1ff
child 959
0e1bf3c199bf
--- a/src/cx/common.h	Tue Oct 22 22:20:50 2024 +0200
+++ b/src/cx/common.h	Tue Oct 22 22:42:48 2024 +0200
@@ -117,6 +117,16 @@
         void *
 );
 
+/**
+ * Determines the number of members in a static C array.
+ *
+ * @attention never use this to determine the size of a dynamically allocated
+ * array.
+ *
+ * @param arr the array identifier
+ * @return the number of elements
+ */
+#define cx_nmemb(arr) (sizeof(arr)/sizeof((arr)[0]))
 
 // Compiler specific stuff
 

mercurial