Wireshark mailing list archives
Re: Allowing use of more C99 features
From: Guy Harris <guy () alum mit edu>
Date: Thu, 1 Sep 2016 19:51:34 -0700
On Sep 1, 2016, at 1:14 PM, Peter Wu <peter () lekensteyn nl> wrote:
Patch https://code.wireshark.org/review/17421 will allow use of some C99 features in master (future 2.4):
For UN*X, with autotools: The AC_PROG_CC_C99 macro is used, and, if it fails to enable what it considers "C99 mode" for the compiler, the configure script will fail. This means some older compilers may not be supported; it's probably time to drop those compilers. The macro appears to try to enable it for: GCC (and Clang), using -std=gnu99 IBM XL C, using -qlanglvl=extc99 HP cc, using -AC99 Intel ICC, using -std=c99 SGI's C compiler for IRIX, using -c99 Sun/Oracle's C compiler, using -xc99=all DEC/Compaq/HP's C compiler for Alpha on Tru64, using -c99 so you're out of luck if you have a version of those compilers that doesn't support those flags and doesn't support all of: _Bool, // comments, flexible array members, inline, signed and unsigned long long int, mixed code and declarations, named initialization of structs, restrict, va_copy, varargs macros, variable declarations in for loops, and variable length arrays For UN*X, with CMake: I'm not sure whether it'll properly enable C99 support for all of the compilers in question. For Windows (CMake assumed), MSVC 2013 supports: // comments as long as you don't compile with /Za, but there might be a warning to suppress; flexible arrays, but there's a warning to suppress, which this change suppresses; inline functions - it might require __inline rather than inline, but GLib is #defining inline to be __inline with MSVC, so we can just use "inline"; mixed code and declarations, but there's a bug that might or might not hit us: https://connect.microsoft.com/VisualStudio/feedback/details/808650/visual-studio-2013-c99-compiler-bug named initialization of structs, but there's a bug that might or might not hit us: https://connect.microsoft.com/VisualStudio/feedback/details/805981 varargs macros, which we're already using; variable declarations in for loops, apparently: http://stackoverflow.com/questions/21696983/error-on-declaring-variable-in-for-statement so, in addition to
- flexible array members - trailing comma in enum declarations - inline function keyword
we also can use // comments and, apparently, variable declarations in for loops, assuming there's no bug that gets in the way. *If* we avoid the bugs, we can also use mixed code and declarations and named initialization of structs. ___________________________________________________________________________ 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:
- Allowing use of more C99 features Peter Wu (Sep 01)
- Re: Allowing use of more C99 features Guy Harris (Sep 01)
- Re: Allowing use of more C99 features Graham Bloice (Sep 02)
- Re: Allowing use of more C99 features Paul Offord (Sep 02)
- Re: Allowing use of more C99 features Graham Bloice (Sep 02)
- Re: Allowing use of more C99 features Graham Bloice (Sep 02)
- Re: Allowing use of more C99 features Guy Harris (Sep 01)