Wireshark-dev: [Wireshark-dev] #ifdef mess
From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Tue, 29 Mar 2016 00:30:10 +0200
Hello list,

I've been meaning to write this mail for some years now but finally got around to it.

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. But apart
from the ugliness of the code, it's the #ifdef mess in our "normal" code. It makes
development on our different platforms a lot more error prone, code validation
along all compile paths basically impossible - in short, we have a configuration
management problem - with our different customers the diffent environments in
which our users build their own Wireshark.
What I would like to see is a drastic reduction of #if HAVE_something_or_other
in the code. Typical methods to reduce that kind of stuff are compile time
variables in those cases where we don't access #included structures directly.
Another method is to have a wrapper library that hides the availability and
structures from the normal code. E.g. it might be a good idea to put the zlib
stuff into a (static) wrapper lib that provides the zlib compile time and run
time version strings as well as a (const) variable that indicates the presence
of zlib at all. There are quite a lot more things that do not need a #ifdef
solution, that way making sure that the preprocessor and compiler get to see
the source and commplain if something is broken even for the non-use case.
Wrt. zlib: Do we really still want to support a case when a build environment
does not provide one?

Done rambling, time to go to bed.

Good night
  Jörg
-- 
Joerg Mayer                                           <jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.