Antonio Diaz Diaz wrote: > The use of 'countof' instead of terminating the array of 'struct > program_option' with an element containing all zeros may be an obstacle for > the adoption of this API outside Gnulib.
Yes, I agree. If we ever want to move this functionality to glibc, either the array shall have an extra null element at the end, or the main entry point shall take 'options' and 'n_options' as separate arguments. But for now, this API is fine, I would say. An API that requires an array be terminated with a null element is also a shortcoming, because a developer may accidentally omit this element. > I found one apparent omission in lib/options.h: > > --- lib/options.h~ 2025-06-26 19:31:53.000000000 +0200 > +++ lib/options.h 2025-06-27 17:22:50.000000000 +0200 > @@ -136,7 +136,7 @@ > handle the option, and when the 'flag' is NULL, getopt_long returns > the value of 'val', as a way to identify which option was seen. > > - It keeps the following properties the getopt_long() API: > + It keeps the following properties of the getopt_long() API: > > * The programmer writes in actions directly in the main() function. > That is, the actions don't go into separate callback functions Thanks; fixed. Bruno