Rusty's obfuscated (but serviceable) macro gets an explanation
Posted Mar 15, 2007 16:41 UTC (Thu) by
pr1268 (subscriber, #24648)
Parent article:
Quotes of the week
Hehe, reading further down the thread, someone asked for some documentation explaining how this macro works.
Rusty obliged the request with:
+/* GCC is awesome. */
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) \
+ sizeof(typeof(int[1 - 2*!!__builtin_types_compatible_p(typeof(arr), \
typeof(&arr[0]))]))*0)
That explains it all so clearly! ;-)
(
Log in to post comments)