I've had to use something like this quite a bit so I guess it's useful
enough to include. It does the same thing as Linux's ARRAY_SIZE macro.
David Vrabel
--
David Vrabel, Design Engineer
Arcom, Clifton Road Tel: +44 (0)1223 411200 ext. 3233
Cambridge CB1 7EA, UK Web: http://www.arcom.com/
Index: ecos-working/packages/infra/current/ChangeLog
===================================================================
--- ecos-working.orig/packages/infra/current/ChangeLog 2006-05-17
16:24:45.000000000 +0100
+++ ecos-working/packages/infra/current/ChangeLog 2006-05-17
16:26:53.000000000 +0100
@@ -1,3 +1,8 @@
+2006-05-17 David Vrabel <[EMAIL PROTECTED]>
+
+ * include/cyg_type.h: #define CYG_ARRAY_SIZE to calculate the
+ number of elements in a (statically allocated) array.
+
2005-11-04 Bart Veer <[EMAIL PROTECTED]>
* tests/cxxsupp.cxx: Fix the compiler warnings.
Index: ecos-working/packages/infra/current/include/cyg_type.h
===================================================================
--- ecos-working.orig/packages/infra/current/include/cyg_type.h 2006-05-17
10:55:22.000000000 +0100
+++ ecos-working/packages/infra/current/include/cyg_type.h 2006-05-17
16:24:06.000000000 +0100
@@ -251,6 +251,11 @@
typedef cyg_haladdrword CYG_ADDRWORD;
// -------------------------------------------------------------------------
+// Number of elements in a (statically allocated) array.
+
+#define CYG_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
+// -------------------------------------------------------------------------
// Constructor ordering macros. These are added as annotations to all
// static objects to order the constuctors appropriately.