Re: clang's -Wmissing-variable-declarations shows some shoddy programming - Mailing list pgsql-hackers

From Andres Freund
Subject Re: clang's -Wmissing-variable-declarations shows some shoddy programming
Date
Msg-id 20131214174724.GF3368@awork2.anarazel.de
Whole thread Raw
In response to Re: clang's -Wmissing-variable-declarations shows some shoddy programming  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2013-12-14 12:14:25 -0500, Tom Lane wrote:
> Andres Freund <andres@2ndquadrant.com> writes:
> > Compiling postgres with said option in CFLAGS really gives an astounding
> > number of warnings. Except some bison/flex generated ones, none of them
> > looks acceptable to me.
> 
> Given that we're not going to be able to get rid of the bison/flex cases,
> is this really something to bother with?

On a second look, it's not that hard to supress the warnings for
those. Something *roughly* like:

/** Declare variables defined by bison as extern, so clang doesn't complain* about undeclared non-static variables.*/
extern int plpgsql_yychar;
extern int plpgsql_yynerrs;

works.

> I agree I don't like cases where
> there's an "extern" in some other .c file rather than in a header, but I'm
> dubious about making a goal of suppressing this warning as such.

The cases where a 'static' is missing imo are cases that should clearly
be fixed, there's just no excuse for them. But it's an easy mistake to
make so having the compiler's support imo is helpful.

WRT the externs in .c files, if it were just old code, I wouldn't
bother. But we're regularly adding them. The last ones just last week in
316472146 and ef3267523 and several others aren't much older. So making
it a policy that can relatively easily be checked automatically not to
do so seems like a good idea.

Unfortunately gcc doesn't have a equivalent warning...

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Changeset Extraction Interfaces
Next
From: Greg Stark
Date:
Subject: Re: stats for network traffic WIP