Reported by Alejandro Colomar <alx@kernel.org>.
* lib/stdcountof.in.h (countof): Parenthesize better.
* modules/stdcountof-h (Description): To appear in C2y, not C23.
2025-06-02 Bruno Haible <bruno@clisp.org>
+ stdcountof-h: Tweaks.
+ Reported by Alejandro Colomar <alx@kernel.org>.
+ * lib/stdcountof.in.h (countof): Parenthesize better.
+ * modules/stdcountof-h (Description): To appear in C2y, not C23.
+
stdcountof-h: Add tests.
* tests/test-stdcountof-h.c: New file.
* tests/test-stdcountof-h-c++.cc: New file.
void func (int a[10]) { ... }
*/
#define countof(a) \
- (sizeof (a) / sizeof (a[0]) + 0 * _gl_verify_is_array (a))
+ (sizeof (a) / sizeof ((a)[0]) + 0 * _gl_verify_is_array (a))
/* Attempts to verify that A is an array. */
#if defined __cplusplus
Description:
-An <stdcountof.h> that is like C23.
+An <stdcountof.h> that is like C2y.
Files:
lib/stdcountof.in.h