Wireshark mailing list archives

Re: Use of variadic macros


From: Evan Huus <eapache () gmail com>
Date: Sun, 23 Sep 2012 20:28:57 -0400

On Sun, Sep 23, 2012 at 6:10 PM, Guy Harris <guy () alum mit edu> wrote:

On Sep 23, 2012, at 1:59 PM, Evan Huus <eapache () gmail com> wrote:

Variadic macros are forbidden in doc/README.developer since apparently
not all compilers support them.

However, I just stumbled across a variadic macro that has apparently
been part of the regular build since around 2009
(packet-dcerpc-netlogon.c:65).

Since nobody (to my knowledge) has complained about a failing build in
that time period, I have to assume that whatever ancient compiler
didn't support them is no longer being used.

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.

I'll leave the README unchanged for the moment then.

Just out of curiosity, has anyone ever tried compiling on Windows with
something like MinGW or another compiler? I expect there would be some
initial pain, but if it allows us to drop MSVC and properly move to
C99, I think would be an overall win.

Evan
___________________________________________________________________________
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: