Ethereal-dev: Re: [Ethereal-dev] Re: [Ethereal-cvs] rev 12842: /trunk/epan/dissectors/: packet

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, 27 Dec 2004 15:27:22 +0100
Michael Tuexen wrote:

Dear all,

can someone explain me the difference between:

typedef enum {
  M2PA_V02 = 1,
  M2PA_V08 = 2,
  M2PA_V12 = 3
} Version_Type;

static Version_Type m2pa_version = M2PA_V12;
...
prefs_register_enum_preference(m2pa_module, "version", "M2PA version", "Version used by Ethereal",
                               (gint *)&m2pa_version,
                               m2pa_version_options, FALSE);

and
typedef enum {
  M2PA_V02 = 1,
  M2PA_V08 = 2,
  M2PA_V12 = 3
} Version_Type;
static gint m2pa_version = M2PA_V12;

prefs_register_enum_preference(m2pa_module, "version", "M2PA version", "Version used by Ethereal",
                               &m2pa_version,
                               m2pa_version_options, FALSE);

In both cases the argument of prefs_register_enum_preference is a pointer to a gint.
Why is it necessary to change the code?

Best regards
Michael

Well, the main reason was a compiler warning in the Solaris buildbot build, with something like:

packet-m2pa.c: In function `proto_register_m2pa':
packet-m2pa.c:576: warning: dereferencing type-punned pointer will break strict-aliasing rules


That was the reason, why I was asking the enum question about prefs_register_enum_preference() using enum types earlier today.

I would think my changes wasn't the best way of doing things, If you know some better way just let me know.

Regards, ULFL