Jeff King [off-list ref] writes:
On Wed, Jul 22, 2009 at 11:34:34PM +0200, Pierre Habouzit wrote:
quoted
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+#define bitsizeof(x) (CHAR_BIT * sizeof(x))
Isn't our style to use all-caps for macros? I.e., BITSIZEOF?
Perhaps but I'd say similarity between sizeof() and bitsizeof() calls for
consistency in the lowercase in this particular case.
On Wed, Jul 22, 2009 at 10:09:56PM -0700, Junio C Hamano wrote:
Jeff King [off-list ref] writes:
quoted
On Wed, Jul 22, 2009 at 11:34:34PM +0200, Pierre Habouzit wrote:
quoted
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+#define bitsizeof(x) (CHAR_BIT * sizeof(x))
Isn't our style to use all-caps for macros? I.e., BITSIZEOF?
Perhaps but I'd say similarity between sizeof() and bitsizeof() calls for
consistency in the lowercase in this particular case.
Fair enough. I just wanted to point it out in case nobody thought of it.
-Peff
On Wed, Jul 22, 2009 at 10:09:56PM -0700, Junio C Hamano wrote:
Jeff King [off-list ref] writes:
quoted
On Wed, Jul 22, 2009 at 11:34:34PM +0200, Pierre Habouzit wrote:
quoted
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+#define bitsizeof(x) (CHAR_BIT * sizeof(x))
Isn't our style to use all-caps for macros? I.e., BITSIZEOF?
Perhaps but I'd say similarity between sizeof() and bitsizeof() calls for
consistency in the lowercase in this particular case.
Yes, I usually have a few other macros that I use in code I write,
namely bitsizeof, fieldsizeof, fieldtypeof and a couple other, and all
are lowercased because:
- it's a safe macro (doesn't multi-evaluate its arguments), hence the
user doesn't really need to know it's a macro ;
- similarity with sizeof().
--
Intersec <http://www.intersec.com>
Pierre Habouzit [off-list ref]
Tél : +33 (0)1 5570 3346
Mob : +33 (0)6 1636 8131
Fax : +33 (0)1 5570 3332
37 Rue Pierre Lhomme
92400 Courbevoie