Wireshark-dev: Re: [Wireshark-dev] #ifdef mess

From: Alexis La Goutte <alexis.lagoutte@xxxxxxxxx>
Date: Thu, 31 Mar 2016 09:09:35 +0200


On Tue, Mar 29, 2016 at 3:48 AM, Guy Harris <guy@xxxxxxxxxxxx> wrote:
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.
You can set also
 g_string_append_printf(str, "without libz");


___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe