This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Plugin Dissector Compilation Error “request for implicit conversion .."

0

I'm trying to test a dissector plug in for wireshark in Linux by following these steps. When I use sudo make -C plugins, I get several similar compilation errors say that MySourceFileDissectorName.c: In function 'X': MySourceFileDissectorName.c:990:11: error: request for implicit conversion from 'gpointer' to 'some struct data type *' not permitted in C++ [-Werror=c++-compat] .... etc.

I've no idea what the cause of the error or how can I resolve it. Any ideas or hints!

Thanks in advance!

asked 15 Jun '14, 14:18

flora's gravatar image

flora
156313338
accept rate: 100%

sudo make -C plugins

You should not run your compiler as root. Neither should you run Wireshark as root.

(16 Jun '14, 02:28) Jaap ♦

Thanks for your comment but Why not?!

(16 Jun '14, 10:45) flora
1

Because any program running as root has the ability to do many more harmful things to your system than a program running under your own user ID, so a bug (or misfeature!) in the compiler, or linker, or "make", or Wireshark, or... can cause more problems if you run the program as root than if you run it as yourself.

(16 Jun '14, 10:52) Guy Harris ♦♦

Thank you so much Guy! I've come across Jaap's comment several times in different contexts and just now I knew the reason behind that.

(16 Jun '14, 11:22) flora

One Answer:

1

The cause of the error is that

  • C++, unlike C, does not allow void * (gpointer is a GLib alias for void *) to be cast to another type value without a case;
  • we want to make sure our C code can be compiled by C++ compilers;

so we build the code with "-Werror=c++-compat".

You resolve it by doing

void *foo;
struct hello *bar;
...

bar = (struct hello *)foo;

rather than

void *foo;
struct hello *bar;

...

bar = foo;

answered 15 Jun ‘14, 15:49

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196
accept rate: 19%

Thank you. This solves the problem.

(16 Jun ‘14, 09:24) flora