Wireshark mailing list archives

Re: #ifdef mess


From: Guy Harris <guy () alum mit edu>
Date: Mon, 28 Mar 2016 18:48:29 -0700

On Mar 28, 2016, at 3:30 PM, Joerg Mayer <jmayer () loplof de> wrote:

Earlier today I committed 30900b443b85a7e760d703ca3d6efe61df4fe623, which I'm
incredibly unproud of because of readablity:

static void
-get_reordercap_runtime_info(GString *str _U_)
+get_reordercap_runtime_info(
+#if defined(HAVE_LIBZ) && !defined(_WIN32)
+    GString *str)
+#else
+   GString *str _U_)
+#endif
{

It fixes the error at hand, but that is about all the good I can say about it.
Oh, and it matches the elegance of the code above and below it.
If someone has a better readable solution to that, please go ahead.

Whether it's *better*, I don't know, but there's

static void
get_reordercap_runtime_info(GString *str)
{
    /* zlib */
#if defined(HAVE_LIBZ) && !defined(_WIN32)
    g_string_append_printf(str, ", with libz %s", zlibVersion());
#else
    g_string_append_printf(str, "");
#endif
}

which is a bit of a greasy hack - appending an empty string to str, just so it's marked as used - but I suspect the 
extra CPU time spent doing that, on platforms unlucky enough not to have zlib, will be lost in the noise.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe


Current thread: