Ethereal-dev: RE: [Ethereal-dev] README.developer - if (tree)

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Biot Olivier <Olivier.Biot@xxxxxxxxxxx>
Date: Wed, 17 Dec 2003 00:25:29 +0100
| From: Devin Heitmueller
| 
| On Tue, 2003-12-16 at 17:52, Biot Olivier wrote:
| > Unless you use double parentheses, like in:
| > 
| > #define IF_proto_tree_add_string(tree, x) \
| > if (tree) proto_tree_add_string x
| > 
| > You'll have to write:
| > 
| > IF_proto_tree_add_string(my_tree, (my_tree, hf_name,
| > 		tvb, start, len, "%s = %u",
| > 		s_name, index));
| 
| Ugh.  That's even more ugly than just having "if (tree)"

Agreed. But I use this trick in debug logging, where it's slightly mode
acceptable:

#ifdef DEBUG_wsp
#define DebugLog(x) \
	printf("%s:%u: ", __FILE__, __LINE__); \
	printf x; \
	fflush(stdout)
#else
#define DebugLog(x) ;
#endif

And then you can write stuff like:

DebugLog(("add_headers(code page 0): %s\n",
			match_strval (hdr_id & 0x7f, vals_field_names)));

I think that's acceptable :)

Regards,

Olivier