[haiku-development] Re: RFC: B_COUNT_OF in SupportDef

  • From: Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 09 Nov 2014 15:23:00 -0600

On , Alexander von Gluck IV wrote:
Anyone have any issues with me adding the following macro?

diff --git a/headers/os/support/SupportDefs.h b/headers/os/support/SupportDefs.h
index 7e47018..e4f6293 100644
--- a/headers/os/support/SupportDefs.h
+++ b/headers/os/support/SupportDefs.h
@@ -202,6 +202,9 @@ extern void*        get_stack_frame(void);
 }
 #endif

+/* Count items in an array, count_of is a common define */
+#define B_COUNT_OF(a) (sizeof(a) / sizeof(a[0]))
+
 /* Obsolete or discouraged API */

 /* use 'true' and 'false' */


It seems like we implement this a lot. radeon_hd, intel_extreme, and
i'm sure a lot of other places.

 -- Alex

Pushed after an hour.. broke some gcc2 builds due to conversions to (int).
Working through repairing those now.  Sorry for the spam.

Other related posts: