Re: clang's -Wmissing-variable-declarations shows some shoddy programming

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: clang's -Wmissing-variable-declarations shows some shoddy programming
Дата
Msg-id 20131214174724.GF3368@awork2.anarazel.de
обсуждение исходный текст
Ответ на Re: clang's -Wmissing-variable-declarations shows some shoddy programming  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Changeset Extraction Interfaces
Следующее
От: Greg Stark
Дата:
Сообщение: Re: stats for network traffic WIP