chiark / gitweb /
utils/macros.h (N): Properly parenthesize the argument.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 15 Jul 2018 18:26:55 +0000 (19:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 15 Jul 2018 18:26:55 +0000 (19:26 +0100)
WTF?  How did I write this wrong?

Fortunately, I don't think it actually matters.  The argument must have
array type.  Postfix operators are higher precedence, so that's not a
problem; prefix operators are in the right place already; and binary
operators don't yield array types.

utils/macros.h

index bcceecd05c9c6a7fa6ce29ce519d998b4ba5bea5..8f9f49e8d0ef4a51c5f2cf778a717076ee3fed1d 100644 (file)
@@ -40,7 +40,7 @@
 
 /*----- Miscellaneous utility macros --------------------------------------*/
 
 
 /*----- Miscellaneous utility macros --------------------------------------*/
 
-#define N(v) (sizeof(v)/sizeof(*v))
+#define N(v) (sizeof(v)/sizeof(*(v)))
 
 #define MLIB__STR(x) #x
 #define STR(x) MLIB__STR(x)
 
 #define MLIB__STR(x) #x
 #define STR(x) MLIB__STR(x)