Wireshark mailing list archives

Re: Idle Thought - Compiling with C++


From: Evan Huus <eapache () gmail com>
Date: Mon, 11 Feb 2013 19:09:08 -0500

On Mon, Feb 11, 2013 at 6:42 PM, Ed Beroset <beroset () mindspring com> wrote:
Evan Huus wrote:

On Mon, Feb 11, 2013 at 1:47 PM, Guy Harris <guy () alum mit edu>
wrote:


Note all the lines flagged with "[-Wc++-compat]"; those are for
code that's valid C but not valid C++ and that would have to be
fixed in order to compile with a C++ compiler (unless there's a
"let valid C code that *could* be handled as C++ code through"
option to all C++ compilers we'd be likely to use).


As per Jakub, we have about 7k of those at the moment. The vast
majority appear to be missing casts from void pointers, which are at
least not difficult to fix (especially since I think many are in
generated code).


I looked at some of those from a dissector I wrote, and I'm pretty sure
I can rewrite to avoid most or all of those, and can use the C-style cast
such as "r = (guint *)ptr;" which will also work with C compilers, or I
could use the C++ style: "r = static_cast<guint *>(ptr);"  For those not
familiar with the new style casts in C++, here's a quick pointer:
http://www.cplusplus.com/doc/tutorial/typecasting/

Given that we haven't made the transition yet, I'm inclined to use the
C-style casts for now.  Anybody have a differing opinion?

If we do plan to migrate we will definitely be using only C-style
constructs to start. It will be enough work transitioning compilers
without changing language constructs at the same time.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe


Current thread: