Re: fdprintf() Anyone?
John Scott <[email protected]> Fri, 12 Dec 2025 00:19:01 +0000
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
Joel Sherrill wrote: > int fdprintf (int fd, const char *format,...) POSIX.1-2008 has already standardized a version of printf() for writing to file descriptors, and it has the same prototype: it's called dprintf (without the 'f' at the beginning). There is also a va_list variant named vdprintf(). These are widely available and I think GNU folks drove their specification. These are already included at https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/stdio/dprintf.c however I think the following text is no longer accurate: > PORTABILITY > This function is originally a GNU extension in glibc and is not portable. Post-standardization I think implementations picked this up without hesitation. You probably just missed this; in fact, dprintf() returns the same value as fdprintf() does to indicate success or error. I think the NetBurner folks giving their function a different name was, at least in hindsight, a botch. > But the user is using a system where they are in <fcntl.h>. For compatibility with that particular application I'm sure you could make fdprintf() an alias for dprintf(). If a user is wanting to use Newlib with NetBurner such a shim might be welcome in a directory specific to that class of systems. > Is there any interest in these eventually landing in newlib? The equivalent standard functions are already in Newlib and my preference (as someone who, to be frank, has never contributed to Newlib) is to do nothing here. If your users are porting an application away, defining '-Dfdprintf=dprintf' may be all they need to do.
signature.asc
(application/pgp-signature, 252 B)
-----BEGIN PGP SIGNATURE----- iIgEABYKADAWIQSiPzylvTnZ6xisfzWz9N0oYfTNugUCaTtfbxIcanNjb3R0QHBv c3Rlby5uZXQACgkQs/TdKGH0zboCiQD+L4Uy+46pcCsw5o/KCDpQ9XPfFsqQ9ZXg iwIYDC77a50A/iahHvpKUi16RVKNoQVPK+oOr7BT6YstPPMRGJHEdh0P =KUZv -----END PGP SIGNATURE-----
smime.p7s
(application/pkcs7-signature, 6.1 KB) - not displayed