Ralf Wildenhues wrote:
* Ralf Wildenhues wrote on Tue, Apr 24, 2007 at 08:53:46AM CEST:
* Charles Wilson wrote on Tue, Apr 24, 2007 at 04:34:41AM CEST:
Ralf Wildenhues wrote:
   for (i=0; i<argc+1; i++)
   {
-    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
+    LTWRAPPER_DEBUGPRINTF("(main) newargz[%d]   : %s\n",i,newargz[i]);
     ;
What's that extra ; for BTW?
If !DEBUGWRAPPER, then LTWRAPPER_DEBUGPRINTF() goes away completely, and gcc complains about the empty body in the for loop.
D'oh.  Thanks.

No, wrong.  If LTWRAPPER_DEBUGPRINTF goes away, then the semicolon at
the end of the LTWRAPPER_DEBUGPRINTF line remains.  I don't see how
there can be a warning with one but no warning with two semicolons.
FWIW, my GCC 4.0.3 doesn't warn at all (with -O2 -W -Wall).

Hmm.  The original commit that added this DEBUG() stuff was here:
   cvs diff -r 1.352 -r 1.353 ltmain.in
at libtool toplevel.  It shows:

...
+
+  for (i=0; i<argc+1; i++)
+  {
+    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
+    ;
+  }
+
 EOF

So this one/two semicolon thing was committed all at once. [Aside: cygwin's gcc at that time was 3.3.3]. I *distinctly* remember having to add the second semicolon during my testing before I posted the patch.

Speculation: maybe I originally defined the DEBUG() macro as a 'semicolon-swallowing' form something like:

+#if defined DEBUGWRAPPER
+# define DEBUG(format, ...) \
+    do { fprintf(stderr, format, __VA_ARGS__); } while(0)
+#else
+# define DEBUG(format, ...) \
+#   do { ; } while(0)
+#endif

for whatever reason, so I needed the second semicolon. Or, maybe

+#if defined DEBUGWRAPPER
+# define DEBUG(args) printf(args); << not fprintf! own semicolon
+#else
+# define DEBUG(args)
+#endif

and expected semicolon-less usage like
   DEBUG( ("format string", some, arguments) )



Then, maybe I later fixed the DEBUG() macro to more-or-less its current form:

+#if defined DEBUGWRAPPER
+# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
+#else
+# define DEBUG(format, ...)
+#endif

but never removed the now-superfluous second semicolon. In any case, I *know* the second one was necessary at some point, but perhaps only in my private development.

You're right, tho: it certainly is not needed now.

--
Chuck



Reply via email to