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

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Steele <david(at)pgmasters(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: C99 compliance for src/port/snprintf.c
Date: 2018-08-15 22:54:01
Message-ID: CAEepm=0VJni=K_dAyh84p0hHZ8DNS5Si49eqO_CsoRXoTjcxhw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-www

On Thu, Aug 16, 2018 at 10:40 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> Hi,
>
> On 2018-08-15 18:31:10 -0400, Tom Lane wrote:
>> Andres Freund <andres(at)anarazel(dot)de> writes:
>> > 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.
>>
>> > I think autoconf's magic knows about most of that:
>> > — Macro: AC_PROG_CC_C99
>>
>> Ah, of course. What about the MSVC build?
>
> It looks like it mostly just enables that by default. But I only looked
> cursorily. It's a bit annoying because that makes it harder to be sure
> which animals support what. Looks like e.g. hammerkop (supposedly msvc
> 2005) might not support the subset we want; not that I'd loose sleep
> over raising the minimum msvc in master a bit.

Really? I am not an MSVC user but I had the impression that their C
mode (/TC or files named .c) was stuck on C89/C90 as a matter of
policy, as Herb Sutter explained here (though maybe the situation has
changed since then):

https://herbsutter.com/2012/05/03/reader-qa-what-about-vc-and-c99/

That's presumably why cfbot's appveyor build always complains about
people declaring variables after statements. To allow that particular
language feature, it looks like you have to tell it that your .c file
is really a C++ program with /TP. But that opens a separate can of
worms, doesn't it?

--
Thomas Munro
http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-08-15 23:00:50 Re: C99 compliance for src/port/snprintf.c
Previous Message Shay Rojansky 2018-08-15 22:50:26 Re: Stored procedures and out parameters

Browse pgsql-www by date

  From Date Subject
Next Message Tom Lane 2018-08-15 23:00:50 Re: C99 compliance for src/port/snprintf.c
Previous Message Andres Freund 2018-08-15 22:40:26 Re: C99 compliance for src/port/snprintf.c