Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Bruno Haible via Gnulib discussion list
Hi Paul, > > + (sizeof (a) / sizeof ((a)[0]) + 0 * _gl_verify_is_array (a)) > > As a minor point, that expression has the wrong type on theoretical (but > standard-conforming) platforms where size_t is narrower than int. I > installed the attached to address this, plus avoid a bit of namespace

Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Paul Eggert
On 6/2/25 15:50, Bruno Haible via Gnulib discussion list wrote: + (sizeof (a) / sizeof ((a)[0]) + 0 * _gl_verify_is_array (a)) As a minor point, that expression has the wrong type on theoretical (but standard-conforming) platforms where size_t is narrower than int. I installed the attached t

Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Collin Funk
Hi all, Bruno Haible via Gnulib discussion list writes: >> > 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. Alejandro, I did not read all the do

Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Bruno Haible via Gnulib discussion list
Alejandro Colomar wrote: > > That should say C2y; C23 didn't have . > > 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 a

Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Bruno Haible via Gnulib discussion list
Alejandro Colomar wrote: > # define countof(a) (sizeof(a) / sizeof((a)[0]) + must_be(is_array(a))) > #endif > > must_be(is_array(a)) is a trick to assert that the argument is an array. >

Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Alejandro Colomar
Hi Bruno, On Tue, Jun 03, 2025 at 12:21:53AM +0200, Alejandro Colomar wrote: > > 2025-06-02 Bruno Haible > > > > stdcountof-h: Add tests. > > * tests/test-stdcountof-h.c: New file. > > * tests/test-stdcountof-h-c++.cc: New file. > > * modules/stdcountof-h-tests: New file. > >

Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Alejandro Colomar
Hi Bruno, On Tue, Jun 03, 2025 at 12:00:22AM +0200, Bruno Haible wrote: > Alejandro Colomar wrote: > > # define countof(a) (sizeof(a) / sizeof((a)[0]) + must_be(is_array(a))) > > #endif > > > > must_be(is_array(a)) is a trick to assert that the argument is an array. > >

Re: stddef-h: Make 'unreachable' usable in C++ mode

2025-06-02 Thread Bruno Haible via Gnulib discussion list
Last week, I did this: > * lib/stddef.in.h: In C++ mode, include and either import > 'unreachable' from the std namespace or define it as an inline function. Unfortunately, that does not work across platforms. On FreeBSD 14, for example, the #include from within stddef.h (which gets

Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Jeffrey Walton
On Mon, Jun 2, 2025 at 7:29 AM Bruno Haible via Gnulib discussion list wrote: > > Hi Alejandro, > > > I've added the _Countof to ISO C2y and GCC 16. Clang 21 has also added > > it. There's a compiler header with a countof macro too. > >

Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Alejandro Colomar
Hi Bruno, On Mon, Jun 02, 2025 at 02:32:46PM +0200, Bruno Haible wrote: > Hi Alejandro, > > > - I have plans for improving _Countof as a GNU extension to work on > >array parameters to functions. I mean making this possible: > > > > wchar_t * > > wmemset(size_t n; wchar_t wcs[n], w

Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Bruno Haible via Gnulib discussion list
Hi Alejandro, > - I have plans for improving _Countof as a GNU extension to work on >array parameters to functions. I mean making this possible: > > wchar_t * > wmemset(size_t n; wchar_t wcs[n], wchar_t wc, size_t n) > { > for (size_t i = 0; i < countof(wcs);

Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Alejandro Colomar
Hi Bruno! On Mon, Jun 02, 2025 at 01:28:31PM +0200, Bruno Haible wrote: > Hi Alejandro, > > > I've added the _Countof to ISO C2y and GCC 16. Clang 21 has also added > > it. There's a compiler header with a countof macro too. > >

_Countof operator and countof macro (C2y)

2025-06-02 Thread Alejandro Colomar
Hi! I've added the _Countof to ISO C2y and GCC 16. Clang 21 has also added it. There's a compiler header with a countof macro too.

Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Bruno Haible via Gnulib discussion list
Oops. I withdraw what I wrote about .

Re: _Countof operator and countof macro (C2y)

2025-06-02 Thread Bruno Haible via Gnulib discussion list
Hi Alejandro, > I've added the _Countof to ISO C2y and GCC 16. Clang 21 has also added > it. There's a compiler header with a countof macro too. > > >

Re: [PATCH] open, openat: handle O_DIRECTORY on special files

2025-06-02 Thread Bruno Haible via Gnulib discussion list
Paul Eggert wrote: > * tests/test-open.h (test_open): Fail if test takes too long > because we tried to open a fifo. Test opening /dev/null, > /dev/tty and a fifo, with a trailing "/" and with O_DIRECTORY. The CI reports a failure of these new tests on native Windows (mingw, MSVC): FAIL: test-op

Re: move kwset to gnulib?

2025-06-02 Thread Paul Eggert
On 2025-06-01 00:45, Bruno Haible wrote: Paul, Jim: Would it be OK to move them to a Gnulib module? Sounds good to me.