From: Greg T. <gd...@le...> - 2024-07-11 14:27:00
|
Solomon Peachy via Gimp-print-devel <gim...@li...> writes: > On Wed, Jul 10, 2024 at 08:26:56PM -0400, Greg Troxel wrote: >> Strictly, a program should specify --std=cNN for the variant it is >> written in. But I think the default -- so far -- is almost always c99 >> so often this doesn't happen. > > gcc jumped from 'gnu89' straight to 'gnu11' and currently defaults to > 'gnu17'. At no point did GCC ever default to c99 (or gnu99). Wow, but I learn something new every day. Anyway, I think we'll all happy with --std=c99. >> I ran make check, and it passed ppds and is still going. > > This will take some hours depending on the speed of your system. It took 12 hours, and that's on a 9th-gen i7! But I got a clean pass. > What does 'man strdup' and 'man localtime_r' list as requirements for > use on these problematic platforms? On NetBSD, strdup says the following (leaving out stuff in the middle) and it works without any defines. SYNOPSIS #include <string.h> char * strdup(const char *str); char * strndup(const char *str, size_t len); STANDARDS The strdup() function conforms to IEEE Std 1003.1-2001 (“POSIX.1”). HISTORY The strdup() function first appeared in 4.4BSD. The strndup() function was added in NetBSD 4.0. man localtime_r says: SYNOPSIS #include <time.h> struct tm * localtime_r(const time_t * restrict clock, struct tm * restrict result); STANDARDS The ctime(), difftime(), asctime(), localtime(), gmtime() and mktime() functions conform to ANSI X3.159-1989 (“ANSI C89”). Rest of the functions conform to IEEE Std 1003.1-2008 (“POSIX.1”). >> I don't have an inkjet printer any more, but from my viewpoint the only >> thing wrong is the POSIX_C_SOURCE define. > > Upstream will _not_ apply this as it will break compilation on > bog-standard Linux systems. I am not really saying you should never define it. Just that you should only define it on systems known to need it, where any remediation of defining additional visibility defines can be done. When you use a visibility define, then the system is supposed to hide everything that is not required by that define. I am unclear on the relationship of system headers to these, specifically if there is an expectation that system headers that are *not* required by that posix level will work. People often (on NetBSD) define _NETBSD_SOURCE, to get back the things that are beyond posix that are defined by NetBSD. I find it strange that strdup is not available on Linux without a define, given that it has been in base posix since 2001 and is from 4.4BSD which is roughly contemperaneous with the start of Linux. But if that's how it is that's how it is. I compiled this hacky test program on Raspberry Pi OS 12 (which is ~debian): #include <string.h> int main() { char *a, *b; a = "foo"; b = strdup(a); return 0; } and it compiled without warnings. It also compiled without warnings on real Debian 12 (x86_64), which has gcc 12.2.0. If you aren't willing to basically guard the _POSIX_C_SOURCE define with "#if linux", then please at least omit it if NetBSD or macOS. It is likely it needs to be omitted the rest of the BSDs as well. I append NetBSD's sys/featuretest.h. As far as I know this is what is supposed to happen. /* $NetBSD: featuretest.h,v 1.10 2013/04/26 18:29:06 christos Exp $ */ /* * Written by Klaus Klein <kl...@Ne...>, February 2, 1998. * Public domain. * * NOTE: Do not protect this header against multiple inclusion. Doing * so can have subtle side-effects due to header file inclusion order * and testing of e.g. _POSIX_SOURCE vs. _POSIX_C_SOURCE. Instead, * protect each CPP macro that we want to supply. */ /* * Feature-test macros are defined by several standards, and allow an * application to specify what symbols they want the system headers to * expose, and hence what standard they want them to conform to. * There are two classes of feature-test macros. The first class * specify complete standards, and if one of these is defined, header * files will try to conform to the relevant standard. They are: * * ANSI macros: * _ANSI_SOURCE ANSI C89 * * POSIX macros: * _POSIX_SOURCE == 1 IEEE Std 1003.1 (version?) * _POSIX_C_SOURCE == 1 IEEE Std 1003.1-1990 * _POSIX_C_SOURCE == 2 IEEE Std 1003.2-1992 * _POSIX_C_SOURCE == 199309L IEEE Std 1003.1b-1993 * _POSIX_C_SOURCE == 199506L ISO/IEC 9945-1:1996 * _POSIX_C_SOURCE == 200112L IEEE Std 1003.1-2001 * _POSIX_C_SOURCE == 200809L IEEE Std 1003.1-2008 * * X/Open macros: * _XOPEN_SOURCE System Interfaces and Headers, Issue 4, Ver 2 * _XOPEN_SOURCE_EXTENDED == 1 XSH4.2 UNIX extensions * _XOPEN_SOURCE == 500 System Interfaces and Headers, Issue 5 * _XOPEN_SOURCE == 520 Networking Services (XNS), Issue 5.2 * _XOPEN_SOURCE == 600 IEEE Std 1003.1-2001, XSI option * _XOPEN_SOURCE == 700 IEEE Std 1003.1-2008, XSI option * * NetBSD macros: * _NETBSD_SOURCE == 1 Make all NetBSD features available. * * If more than one of these "major" feature-test macros is defined, * then the set of facilities provided (and namespace used) is the * union of that specified by the relevant standards, and in case of * conflict, the earlier standard in the above list has precedence (so * if both _POSIX_C_SOURCE and _NETBSD_SOURCE are defined, the version * of rename() that's used is the POSIX one). If none of the "major" * feature-test macros is defined, _NETBSD_SOURCE is assumed. * * There are also "minor" feature-test macros, which enable extra * functionality in addition to some base standard. They should be * defined along with one of the "major" macros. The "minor" macros * are: * * _REENTRANT * _ISOC99_SOURCE * _ISOC11_SOURCE * _LARGEFILE_SOURCE Large File Support * <http://ftp.sas.com/standards/large.file/x_open.20Mar96.html> */ #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) #define _POSIX_C_SOURCE 1L #endif #if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ !defined(_XOPEN_SOURCE) && !defined(_NETBSD_SOURCE) #define _NETBSD_SOURCE 1 #endif #if ((_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500) && \ !defined(_REENTRANT) #define _REENTRANT #endif |