Wireshark-dev: Re: [Wireshark-dev] #ifdef mess
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Mon, 28 Mar 2016 18:48:29 -0700
On Mar 28, 2016, at 3:30 PM, Joerg Mayer <jmayer@xxxxxxxxx> 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.