Alejandro Colomar wrote: > > That should say C2y; C23 didn't have <stdcountof.h>. > > Oh, and another issue: > > $ grepc countof . > ./lib/stdcountof.in.h:#define countof(a) \ > (sizeof (a) / sizeof (a[0]) + 0 * _gl_verify_is_array (a)) > > (a[0]) should be ((a)[0])
Right. Thanks. Fixed as below. > > BTW, do you have in plans for using this module within gnulib itself? Sure. I'll just wait a week or so - to give other people a chance to chime in, - to wait for the weekly CI results. 2025-06-02 Bruno Haible <br...@clisp.org> stdcountof-h: Tweaks. Reported by Alejandro Colomar <a...@kernel.org>. * lib/stdcountof.in.h (countof): Parenthesize better. * modules/stdcountof-h (Description): To appear in C2y, not C23. diff --git a/lib/stdcountof.in.h b/lib/stdcountof.in.h index 3bbb78390a..af62b4d45b 100644 --- a/lib/stdcountof.in.h +++ b/lib/stdcountof.in.h @@ -33,7 +33,7 @@ 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 diff --git a/modules/stdcountof-h b/modules/stdcountof-h index 1408e5ea2b..e8fa277597 100644 --- a/modules/stdcountof-h +++ b/modules/stdcountof-h @@ -1,5 +1,5 @@ Description: -An <stdcountof.h> that is like C23. +An <stdcountof.h> that is like C2y. Files: lib/stdcountof.in.h