Andrew Lunn wrote:
> On Wed, May 17, 2006 at 05:13:47PM +0100, David Vrabel wrote:
>> 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.
>
> I've always called this NELEM.
That would be a more descriptive name. Have another patch so you can
choose which (if any) to apply.
> Is this defined in any standard anywhere?
I don't think so.
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_NELEM 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_NELEM(a) (sizeof(a) / sizeof((a)[0]))
+
+// -------------------------------------------------------------------------
// Constructor ordering macros. These are added as annotations to all
// static objects to order the constuctors appropriately.