Wireshark mailing list archives

Re: Use of variadic macros


From: Guy Harris <guy () alum mit edu>
Date: Mon, 5 Oct 2015 00:58:26 -0700


On Oct 4, 2015, at 7:41 AM, Peter Wu <peter () lekensteyn nl> wrote:

On Thu, Oct 01, 2015 at 10:15:12AM -0700, Guy Harris wrote:

On Oct 1, 2015, at 9:53 AM, Alexis La Goutte <alexis.lagoutte () gmail com> wrote:

Yes, there is a "warning" with GCC from some month...

../../epan/proto.h:2740:54: warning: anonymous variadic macros were introduced in C99 [-Wvariadic-macros]

Perhaps we need to turn on the "use C99" flag for some compilers,
including, but not limited to, GCC-compatible compilers, to suppress
warnings or even errors.

The feature seems supported even in c90 mode on gcc 5.2.0 and clang
3.7.0. After reading the gcc manual page, I've decided to settle with
-Wno-variadic-macros.

And, from 2012:

        https://www.wireshark.org/lists/wireshark-dev/201209/msg00144.html

where "they" refers to variadic macros:

They're supported with Microsoft's compilers at least as far back as Visual Studio 2005:

      http://msdn.microsoft.com/en-us/library/ms177415(v=vs.80).aspx

There's no earlier version of the documentation offered by the "Other Versions" dropdown, but I don't know whether 
that means "earlier compilers, such as MSVC 6, didn't support them" or "we don't have the MSVC 6 documentation 
online".  This page:

      http://bytes.com/topic/c/answers/220087-macros-variable-parameter-list-ms-vc-compiler-6-0-a

has a claim that MSVC 6 didn't support variadic macros.  If that's the case, I don't personally have a problem with 
kicking MSVC 6 to the curb; we may already have done so in the documentation, as

      http://www.wireshark.org/docs/wsdg_html_chunked/ChToolsMSChain.html

only mentions it when it says "The official Wireshark 1.8.x releases are compiled using Microsoft Visual C++ 2010 
SP1. The official 1.2, 1.4, and 1.6 releases are and were compiled using Microsoft Visual C++ 2008 SP1. Other past 
releases, including the 1.0 branch, were compiled using Microsoft Visual C++ 6.0.", and doesn't at all discuss using 
MSVC++ 6.

I don't know what other compilers, such as Sun C^WOracle Solaris Studio, HP's ANSI C compiler, or IBM's XL C support. 
 My *guess* is that older versions of those compilers may not have supported them but that they've all up-to-date 
with C99 features.

Sun C fully supported C99 as of Sun Studio 12 (not to be confused with Sun Studio, Memphis :-)):

      http://docs.oracle.com/cd/E19205-01/820-4155/c.html#about

*if* you specify -xc99; I don't know whether it or later versions support variadic macros without -xc99 or whether 
earlier versions supported them.

IBM C for AIX fully supported C99 as of V6.0 in 2002:

      
http://www-01.ibm.com/common/ssi/cgi-bin/ssialias?infotype=an&subtype=ca&supplier=897&appname=IBMLinkRedirect&letternum=ENUS202-161

and XL C for AIX

      http://www-01.ibm.com/software/awdtools/xlcpp/aix/features/

supports C99 now (with no indication in the document of when it started, but the Wikipedia page for C99, whence I got 
these references, says it started with V11.1).  I don't know whether either of them have separate C89 and C99 modes 
(which they might, for the benefit of those developing code that needs to build on C89 compilers) or whether, in C89 
mode, they support extensions such as variadic macros.  Given that one of IBM's compilers is the reason why we ban // 
comments - it disallows them by default - I suspect that, when not running in C99 (or C11?) mode, they do not support 
them.

The HP ANSI C compiler supports C99 at least as of A.06.25

      http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/Online_Help/getstarted.htm

I don't know whether it has separate C89 and C99 modes (which they might, for the benefit of those developing code 
that needs to build on C89 compilers) or whether, in C89 mode, it supports extensions such as variadic macros.

P.S. Are there any other C99 features that we forbid that are actually
supported by supposedly C89-only compilers like MSVC?

// comments are, I think, supported by MSVC; I don't know whether any UN*X C compilers support them without being 
told to run in C99 or C11 (or "GCC compatible"?) mode.

Turning on "full C99" mode for compilers does run the risk of people using C99 features *not* supported by MSVC++ and 
not having them discovered until the build breaks.

At this point, given Microsoft's apparently-renewed interest in C99, I'd say we should, for all compilers, turn on 
whatever flags are needed to support variadic macros and // comments, and if that means not catching some C99 features 
not supported by MSVC++ prior to the latest version, so be it.

So, yeah, let's go for -Wno-variadic-macros.  I may try running the 2.0-rc1 source tarball through the compilers on The 
Written Word's machines and, if anything breaks, see if there are compiler flags that need to be turned on.

Patch is at https://code.wireshark.org/review/10781

I've reviewed it +2 and submitted it, so it should be in 2.0-rc1 (or rc0 or whatever Gerald calls it).

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe


Current thread: