From: Bruno Haible Date: Mon, 2 Jun 2025 22:48:06 +0000 (+0200) Subject: stdcountof-h: Tweaks. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=073f99896898b757c7c2cdcff82cfedb440346f6;p=thirdparty%2Fgnulib.git stdcountof-h: Tweaks. Reported by Alejandro Colomar . * lib/stdcountof.in.h (countof): Parenthesize better. * modules/stdcountof-h (Description): To appear in C2y, not C23. --- diff --git a/ChangeLog b/ChangeLog index 7f50173924..fc7b56a69a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2025-06-02 Bruno Haible + stdcountof-h: Tweaks. + Reported by Alejandro Colomar . + * 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. 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 that is like C23. +An that is like C2y. Files: lib/stdcountof.in.h