Hi Jakub, On Fri, May 09, 2025 at 10:02:17PM +0200, Jakub Jelinek wrote: > On Fri, May 09, 2025 at 09:32:50PM +0200, Alejandro Colomar wrote: > > gcc/ChangeLog: > > > > * Makefile.in > > Missing (USER_H): Add stdcountof.h.
Thanks! > > --- /dev/null > > +++ b/gcc/ginclude/stdcountof.h > > @@ -0,0 +1,31 @@ > > +/* Copyright (C) 2025 Free Software Foundation, Inc. > > + > > +This file is part of GCC. > > + > > +GCC is free software; you can redistribute it and/or modify > > +it under the terms of the GNU General Public License as published by > > +the Free Software Foundation; either version 3, or (at your option) > > +any later version. > > + > > +GCC is distributed in the hope that it will be useful, > > +but WITHOUT ANY WARRANTY; without even the implied warranty of > > +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > +GNU General Public License for more details. > > + > > +Under Section 7 of GPL version 3, you are granted additional > > +permissions described in the GCC Runtime Library Exception, version > > +3.1, as published by the Free Software Foundation. > > + > > +You should have received a copy of the GNU General Public License and > > +a copy of the GCC Runtime Library Exception along with this program; > > +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > > +<http://www.gnu.org/licenses/>. */ > > + > > +/* ISO C2Y: 7.21 Array count <stdcountof.h>. */ > > + > > +#ifndef _STDCOUNTOF_H > > +#define _STDCOUNTOF_H > > This should define also > __STDC_VERSION_STDCOUNTOF_H__ > macro (guess to 202502L or when the paper has been approved for now > or maybe 202500L as something clearly before that). Hmmm, I was wondering what value I should put there, and eventually I thought I should just remoove it because this has not yet been released by ISO, so technically this is an experimental extension that we think will match a future ISO C release. Please confirm if I should add some value there. > > + > > +#define countof _Countof > > N3550 says > The macro > countof(...) > expands to _Countof(__VA_ARGS__). This is an editorial mistake in the standard. I reported it this morning, and the next draft will be fixed. See my paper below (but it won't be voted nor officially presented, because the changes will be accepted editorially). > > I believe that means it should be function-like macro and > #include <stdcountof.h> > int countof = 42; > IMHO is valid C2Y source. > countof doesn't match any of the J.6.2 patterns, it is listed in J.6.3 > instead. > > Jakub Have a lovely night! Alex --- Name alx-0016r1 - countof shouldn't be function-like Category Operators; consistency Author Alejandro Colomar <a...@kernel.org> History <https://www.alejandro-colomar.es/src/alx/alx/wg14/alx-0016.git/> r0 (2025-05-09): - Initial draft. r1 (2025-05-09): - Fix link. Description The countof() macro wasn't discussed much, since most of the discussion went to the operator, _Countof, and its name. It seems we accidentally merged a macro that requires parentheses, which is inconsistent with the real operator, which we agreed it should not require parentheses. This proposal is consistent with how the macro 'alignof' was specified in C17. <https://web.archive.org/web/20181230041359if_/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf#section.7.15> Proposed wording Based on N3550. 7.21 Array count <stdcountof.h> @@ p2 The macro - countof(...) + countof expands to -<b>_Countof(__VA_ARGS__)</b>. +<b>_Countof</b>. -- <https://www.alejandro-colomar.es/>
signature.asc
Description: PGP signature