Ethereal-dev: [Ethereal-dev] Changes in proto.h, still compiling with gcc?

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

From: Ulf Lamping <ulf.lamping@xxxxxx>
Date: Mon, 10 May 2004 10:35:34 +0200
Hi List!

Could someone send me a response, as I've checked in a change in proto.h, and cannot test it (no working gcc environment). Does the current CVS still compile well with gcc compilers?


I want to get rid of the annoying double definition of the proto_tree_add_xy_format functions, like

/* Add a FT_PROTOCOL to a proto_tree */
#if __GNUC__ >= 2
extern proto_item *
proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
   gint length, const char *format, ...)
   __attribute__((format (printf, 6, 7)));
#else
extern proto_item *
proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
   gint length, const char *format, ...);
#endif


This makes it very hard to read, so I tried to encapsulate the __attribute__ inside a macro:

#if __GNUC__ >= 2
#define GNUC_FORMAT_CHECK(archetype, string_index, first_to_check) __attribute__((format (archetype, string_index, first_to_check)))
#else
   #define GNUC_FORMAT_CHECK(archetype, string_index, first_to_check)
#endif

Now getting (for both MSVC and gcc):

extern proto_item *
proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
   gint length, const char *format, ...) GNUC_FORMAT_CHECK(printf,6,7);


Regards, ULFL