Re: C99 compliance for src/port/snprintf.c

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: David Steele <david(at)pgmasters(dot)net>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: C99 compliance for src/port/snprintf.c
Date: 2018-08-15 22:24:01
Message-ID: 20180815222401.kxsupl5zie2jgi4x@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-www

Hi,

On 2018-08-15 18:13:59 -0400, Tom Lane wrote:
> Experimenting here says that even reasonably modern gcc's won't take
> declarations-inside-for without "--std=c99" or such. No idea about
> other compilers. So we'd have a little bit of work to do on
> configuration before we could open the floodgates on this.

I think autoconf's magic knows about most of that:

— Macro: AC_PROG_CC_C99

If the C compiler is not in C99 mode by default, try to add an
option to output variable CC to make it so. This macro tries various
options that select C99 on some system or another. It considers the
compiler to be in C99 mode if it handles _Bool, flexible arrays,
inline, long long int, mixed code and declarations, named
initialization of structs, restrict, varargs macros, variable
declarations in for loops and variable length arrays.

After calling this macro you can check whether the C compiler has
been set to accept C99; if not, the shell variable ac_cv_prog_cc_c99
is set to ‘no’. ~

I think we could get a start by adding that test to configure, without
relying on it for now (i.e. keeping mylodon with -Wc99-extensions
-Werror=c99-extensions alive). That'd tell us about which machines,
besides presumably gaur, we'd need to either kick to the curb or change.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-08-15 22:31:10 Re: C99 compliance for src/port/snprintf.c
Previous Message Jonathan S. Katz 2018-08-15 22:23:40 Re: xact_start meaning when dealing with procedures?

Browse pgsql-www by date

  From Date Subject
Next Message Tom Lane 2018-08-15 22:31:10 Re: C99 compliance for src/port/snprintf.c
Previous Message Tom Lane 2018-08-15 22:18:21 Re: C99 compliance for src/port/snprintf.c