Ethereal-dev: Re: [Ethereal-dev] Patch: value_string convenience macros

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

From: Michael Tuexen <Michael.Tuexen@xxxxxxxxxxxxxxxxx>
Date: Sun, 22 Feb 2004 23:58:58 +0100
Just a suggestion,

I'm using a similar macro for defining a lot of things but it is like
#define VS_DEF(x) { x, #x },

I can then write

static const value_string var [] = {
  VS_DEF(ONE)
  VS_DEF(TWO)
  VS_DEF(THREE)
  VS_END };

It saves to append the ',' at the end of VS_DEF.

Best regards
Michael

On 22. Feb 2004, at 23:48 Uhr, Guy Harris wrote:

On Thu, Feb 19, 2004 at 12:58:41PM -0500, Peter J. Creath wrote:
The patch attached adds the VS_DEF(x) and VS_END macros.

Checked in.

They let
you define value_string arrays in a somewhat more convenient fashion
when dealing with enums:

...or when dealing with #defines...

...but *ONLY* in those cases where the string corresponding to the value happens to be the enum or #define name, which is very often not the case
for value_string tables - because, for one thing, people might not
happen to just know the name in question or that name might not be
descriptive enough, or because the name might have extra information in
it such as the IPSEC_ in the #defines for various security levels in the
IP security option.

_______________________________________________
Ethereal-dev mailing list
Ethereal-dev@xxxxxxxxxxxx
http://www.ethereal.com/mailman/listinfo/ethereal-dev