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

clang: -Wc++-compat fails

0

I am on FreeBSD 6.3, using clang 3.1 to build wireshark.

I am getting the following error during compile. The question is, what purpose is -Wc++-compat playing? Should it really be turned on here?

I am actually tempted to remove "#ifndef __GNUC__" from smi.h.

  CC     libwireshark_la-epan.lo
In file included from epan.c:31:
In file included from ../wsutil/wsgcrypt.h:63:
...
In file included from epan.c:63:
/usr/local/include/smi.h:319:1: error: empty struct has size 0 in C, size 1 in
      C++ [-Werror,-Wc++-compat]
} SmiElement;
^
6 warnings and 1 error generated.
gmake[3]: *** [libwireshark_la-epan.lo] Error 1

asked 08 Oct '13, 13:25

tdprime's gravatar image

tdprime
1222
accept rate: 0%

edited 17 Oct '13, 16:04

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196

I have forwarded the following fix to the people of the libsmi project:

/ SmiElement -- an item in a list (row index column, notification object) / typedef struct SmiElement { +#ifdef clang + char dummy; / CLANG complains about this with -WC++-compat / +#endif #ifndef GNUC char dummy; / many compilers are unhappy with empty structures. / #endif / no visible attributes / } SmiElement;

(I give up on formatting this.....)

(28 Jan '14, 13:04) MavEtJu

2 Answers:

1

The purpose behind having that flag turned on was to allow C++ compilers to be used to compile Wireshark. During the initial cleanup to make that possible, a number of latent bugs were also discovered and fixed. The flag was then turned on to avoid re-introducing incompatibilities. See Wireshark bug #8416 for more details on the why and how. In your case, it looks as though you have a C++ incompatible system file. You could either modify that file (or perhaps see if there is a newer version that someone else has already fixed?) or temporarily remove the flag from your compilation. If you think this is an issue that will affect other FreeBSD users, you might consider filing a bug report in bugzilla.

answered 08 Oct '13, 13:38

beroset's gravatar image

beroset
2261213
accept rate: 33%

0

I ran into this as well. I worked around it by removing #ifndef __GNUC__ from smi.h. Passing --disable-warnings-as-errors to configure would probably have worked as well.

answered 17 Oct '13, 14:19

Gerald%20Combs's gravatar image

Gerald Combs ♦♦
3.3k92258
accept rate: 24%

edited 17 Oct '13, 16:14