tcpdump mailing list archives

Re: [tcpdump] About HAVE_NO_PRINTF_Z


From: Guy Harris via tcpdump-workers <tcpdump-workers () lists tcpdump org>
Date: Wed, 11 Jan 2023 23:06:23 -0800

--- Begin Message --- From: Guy Harris <gharris () sonic net>
Date: Wed, 11 Jan 2023 23:06:23 -0800
On Jan 11, 2023, at 10:44 PM, Francois-Xavier Le Bail via tcpdump-workers <tcpdump-workers () lists tcpdump org> wrote:

The commit fbd44158e0d5e6bb0c9b05671f702ebcf68cc56d was:
-------------------------------------------------------------------------------
   Mend "make check" on Solaris 9 (Autoconf only).

   Sun C 5.9 does not support C99. GCC 4.6.4 recognizes -std=gnu99, but
   does not support the z length modifier in printf(3). In either case 18
   tests fail in the following manner:

   <     [...]: domain [length 0 < 12] (invalid)
   ---
   >     [...]: domain [length 0 < zu] (invalid)

   Make these tests conditional and disable them when HAVE_NO_PRINTF_Z is
   defined. Modify the Autoconf leg of the build process to define the
   macro when printf() does not handle %zu as expected. The CMake leg looks
   broken on Solaris 9 with 2.8.9 now, so leave it be for now.
-------------------------------------------------------------------------------

I think that if a compiler builds a tcpdump that outputs "zu" when it must output "12", it's an error and this 
compiler must be tag "unsupported".

It's probably more the library - %z is interpreted by the library at run time, not by the compiler at compile time 
(except to the extent that the compiler does format/argument checking).

On UN*Xes, the C library is typically the system API library, so it's bundled with the OS rather than the compiler, so 
I don't know whether this is an issue of Sun C 5.9 or SunOS 5.9 (the core OS part of Solaris 9).

Unfortunately, I'm not sure to what extent either autoconf's "is C99 supported?" or CMake's "is C99 supported?" can, or 
does, check for library support, and various "I want C99" flags to the compiler may affect which version of the 
language the compiler accepts and supports but it might not guarantee that the library with which the program will be 
linked supports that version of the language.

But it might make sense to just say "%z" is required by current versions of tcpdump (and libpcap), even if the lack of 
that support can't be discovered until "zu" shows up in output, as long as we don't have to worry about older OS 
versions if printf-formatting routines are part of an OS library rather than a C compiler support library.

--- End Message ---
_______________________________________________
tcpdump-workers mailing list
tcpdump-workers () lists tcpdump org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers

Current thread: