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

Ethereal-dev: Re: [Ethereal-dev] stricter GCC (was: Re: [Patch] iostat win32 build)

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <guy@xxxxxxxxxx>
Date: Mon, 2 Dec 2002 13:31:15 -0800
On Mon, Dec 02, 2002 at 02:22:55PM -0700, John McDermott wrote:
> I propose
> -std=c99
> as a possible option to use.

	hostname$ gcc -std=c99 foo.c
	cc1: unknown C standard `c99'
	hostname$ gcc --version
	2.95.1f

> That would ensure compliance with C99 which is ISO/IEC 9899.

Not all compilers with which Ethereal would be built support C99.  I'd
vote for C89; unfortunately, that's not strong enough:

	hostname$ cat foo.c
	#include <stdio.h>

	void
	foo(int a)
	{
		switch (a) {

		case 1:
			printf("Yes\n");
			break;

		case 2:
			printf("No\n");
			break;

		default:
		}
	}
	hostname$ gcc -c -Wall -W -std=c89 foo.c
	hostname$

"-pedantic" does the trick:

	hostname$ gcc -c -Wall -W -pedantic -std=c89 foo.c
	foo.c: In function `foo':
	foo.c:17: warning: ANSI C forbids label at end of compound statement
	hostname$ 

and, in fact, does it without "-std=c89":

	hostname$ gcc -c -Wall -W -pedantic foo.c
	foo.c: In function `foo':
	foo.c:17: warning: ANSI C forbids label at end of compound statement
	hostname$ 

"-pedantic" might produce too many warnings to be generally useful, i.e.
it might drown you in warnings that can't be fixed.  If so, it could be
added to the list of extra GCC options that "--with-extra-gcc-checks"
now enables - I checked that in recently; it currently turns on
"-Wcast-qual" and "-Wcast-align".