Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: [Wireshark-dev] Do we still need/want -Wc++-compat?

Date Prev · Date Next · Thread Prev · Thread Next
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Wed, 30 Sep 2015 18:53:06 -0700
I think the intent was to be able to run Wireshark's C code through C++ compilers; I can't find the mail where this was discussed, but, as I remember, the issue was that Microsoft were dragging their feet on C99 support, and we wanted to be able to use at least some features present in both C99 and the versions of C++ supported by the Microsoft compiler.

Microsoft have gotten more receptive to C99 features; is this something we still want to contemplate - and to try to keep open as a possibility, by compiling with -Wc++-compat?

If I try to build what's currently in master, it fails on my Yosemite machine, with Xcode 7.0.1, with

In file included from oids.c:42:
/usr/local/include/smi.h:314:9: error: empty struct has size 0 in C, size 1 in C++ [-Werror,-Wc++-compat]
typedef struct SmiElement {
        ^
1 error generated.
In file included from epan.c:58:
/usr/local/include/smi.h:314:9: error: empty struct has size 0 in C, size 1 in C++ [-Werror,-Wc++-compat]
typedef struct SmiElement {
        ^

although, mysteriously, it does *not* fail on my El Capitan virtual machine, also with Xcode 7.0.1, and the same version of libsmi installed.

I don't know why it's not failing with other compilers; perhaps this is a new check added in the version of clang in Xcode 7.

The offending structure is

/* SmiElement -- an item in a list (row index column, notification object)   */
typedef struct SmiElement {
#ifndef __GNUC__
    char dummy;		/* many compilers are unhappy with empty structures. */
#endif
    /* no visible attributes */
} SmiElement;