On 11/22/19 10:07 AM, enh wrote: > On Fri, Nov 22, 2019 at 4:53 AM Rob Landley <[email protected]> wrote: >> >> On 11/21/19 4:13 PM, enh via Toybox wrote: >>> Includes new tests. >>> --- >>> lib/portability.h | 3 ++ >> >> Applied, by why add this #include to portability.h when it's not in an >> #ifdef? >> The main #includes are in toys.h. > > i was going to put it in toys.h initially, but it seemed (from the > comments on each block) like toys.h was only meant for _standard_ > headers? <getopt.h> is a non-standard (but common to BSD, glibc, > bionic, macOS) header that defines the non-standard *long* getopt > functions. the POSIX getopt() function is in <unistd.h>.
It's for unconditionally included headers, and I try to only use standard ones when I can, and the nonstandard ones are generally #included in individual commands so they don't break the build when you switch that command off. Adding something to portability.h that has no #ifdef around it serves no obvious purpose? If you build it on a libc that doesn't have it, the build still breaks, it might as _well_ be in toys.h... That said, reading this header out of /usr/include/getopt.h this one is _weird_. It prototypes getopt() which is also in unistd.h according to: https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/getopt.html This header provides an explicitly non-posix version of a posix function? > if you add a "non-standard but everyone has them" block to toys.h i'll > put any similar future cases there :-) This header is in LSB 4.1: http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic.html#AEN6967 There's already a toys.h section for that. Rob _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
