#define DEBUG 0
#define(a,b,…c) if (debug >= a) fprintf (stdout,b)
dprint (DEBUG, “blabla\n.”);
dprint (DEBUG, "blabla\n %2X %d \n ", aa, bb);
whats wrong?
watcom 10.6
QNX4.25
regards
Andreas
#define DEBUG 0
#define(a,b,…c) if (debug >= a) fprintf (stdout,b)
dprint (DEBUG, “blabla\n.”);
dprint (DEBUG, "blabla\n %2X %d \n ", aa, bb);
whats wrong?
watcom 10.6
QNX4.25
regards
Andreas
On Sun, 7 Dec 2003 12:09:17 +0100, “Andreas” <amathys@bluewin.ch>
wrote:
#define DEBUG 0
#define(a,b,…c) if (debug >= a) fprintf (stdout,b)
As far as I know Watcom doesn’t handle variable numbers of arguments
in defines.
dprint (DEBUG, “blabla\n.”);
dprint (DEBUG, "blabla\n %2X %d \n ", aa, bb);
whats wrong?
watcom 10.6
QNX4.25
regards
Andreas
\
“Carlos Clarke” <carlos@ptdprolog.net> wrote in message
news:0ug9tv04ffmocunq2a7th5pu39mljl4i37@4ax.com…
On Sun, 7 Dec 2003 12:09:17 +0100, “Andreas” <> amathys@bluewin.ch
wrote:#define DEBUG 0
#define(a,b,…c) if (debug >= a) fprintf (stdout,b)
As far as I know Watcom doesn’t handle variable numbers of arguments
in defines.
To my knowledge this isn’t standard C.
dprint (DEBUG, “blabla\n.”);
dprint (DEBUG, "blabla\n %2X %d \n ", aa, bb);
whats wrong?
watcom 10.6
QNX4.25
regards
Andreas
\
Previously, Mario Charest wrote in qdn.public.qnx4:
“Carlos Clarke” <> carlos@ptdprolog.net> > wrote in message
news:> 0ug9tv04ffmocunq2a7th5pu39mljl4i37@4ax.com> …
On Sun, 7 Dec 2003 12:09:17 +0100, “Andreas” <> amathys@bluewin.ch
wrote:#define DEBUG 0
#define(a,b,…c) if (debug >= a) fprintf (stdout,b)
As far as I know Watcom doesn’t handle variable numbers of arguments
in defines.To my knowledge this isn’t standard C.
FWIW, I use the following:
#ifdef DEBUG
#define debug_msg fprintf
#else
#define debug_msg (void)
#endif // DEBUG
You’d apply it something like this:
debug_msg(stderr, “Here’s x, y, and z: %1d, %1d, %1d.\n”, x, y, z);
This macro has a few disadvantages: If there are side-effects
in the parameters, these will occur even when DEBUG is turned off
(which is determined at compile-time, not run-time). Also, the
compiler will complain with:
Warning! W111: Meaningless use of an expression
when DEBUG is turned off. It also wastes some RAM and CPU cycles.
But it’s easy to type.
–
±---- Pete DiMarco ------±--------------------------------------+
| Staff Software Engineer | Web: www.ifspurity.com |
| Integrated Flow Systems | Email: peted [At] ifspurity [Dot] com |
±------------------------±--------------------------------------+
<< Opinions expressed here are my own, not those of my employer. >>
I have a firm solution
#define dprint (a,b) if (debug >= (a)) printf ("%s\n", (b))
int main (int argc, char **argv)
{ int debug = atoi (argv[1]);
dprint (1, “debug message”);
return 0;
}
Andreas schrieb:
#define DEBUG 0
#define(a,b,…c) if (debug >= a) fprintf (stdout,b)
dprint (DEBUG, “blabla\n.”);
dprint (DEBUG, "blabla\n %2X %d \n ", aa, bb);
whats wrong?
watcom 10.6
QNX4.25
regards
Andreas
Dieter Schemmelmann <dieschemm@t-online.de> wrote:
I have a firm solution
#define dprint (a,b) if (debug >= (a)) printf ("%s\n", (b))
int main (int argc, char **argv)
{ int debug = atoi (argv[1]);
dprint (1, “debug message”);
return 0;
}
I use the following for debug:
// set this for debugging
#define VDebug
#ifdef VDebug
extern int optd;
#define CP { if (optd) fprintf (stdout, “[** %s %d **]\n”, FILE, LINE); }
#define D if (optd > 1)
#else // VDebug
#define CP ;
#define D if (0)
#endif // VDebug
Then, in the source, I can do things like:
code
code
D code that only runs during debug
code
I find the “D” at the beginning of the line unobtrusive.
But, as with any coding style, it’s a large part personal preference…
Cheers,
-RK
Andreas schrieb:
#define DEBUG 0
#define(a,b,…c) if (debug >= a) fprintf (stdout,b)
dprint (DEBUG, “blabla\n.”);
dprint (DEBUG, "blabla\n %2X %d \n ", aa, bb);
whats wrong?
watcom 10.6
QNX4.25
regards
Andreas
–
[If replying via email, you’ll need to click on the URL that’s emailed to you
afterwards to forward the email to me – spam filters and all that]
Robert Krten, PDP minicomputer collector http://www.parse.com/~pdp8/