Re: pg_attribute_noreturn(), MSVC, C11 - Mailing list pgsql-hackers

From Andres Freund
Subject Re: pg_attribute_noreturn(), MSVC, C11
Date
Msg-id s67xlw3h4wko4laxi53qizwctdapqfamgjz2vzjny2b4pt7tdx@4cvdfd4f2kgz
Whole thread Raw
In response to Re: pg_attribute_noreturn(), MSVC, C11  (Peter Eisentraut <peter@eisentraut.org>)
List pgsql-hackers
Hi,

On 2024-12-14 18:15:13 +0100, Peter Eisentraut wrote:
> On 13.12.24 20:10, Andres Freund wrote:
> > (or alternatively include stdreturn if __STDC_VERSION__ indicates support and
> > define a bare 'noreturn' if not)
> > 
> > For msvc that mean we'd need to add /std:c11 (or /std:c17) to the compiler
> > flags, as it otherwise it results in a weird mix of c89 an c99). But that
> > might be a good idea anyway. With one minor change [1] the tests pass with
> > msvc when using /std:c17.
> 
> According to my notes, C11 requires MSVC 2019, and we currently require
> 2015, so this will require a bit of logic.

Yea. Not hard though:

@@ -298,6 +298,7 @@ elif host_system == 'windows'
   if cc.get_id() == 'msvc'
     ldflags += '/INCREMENTAL:NO'
     ldflags += '/STACK:@0@'.format(cdata.get('WIN32_STACK_RLIMIT'))
+    cflags += cc.first_supported_argument('/std:c17', '/std:c11')
     # ldflags += '/nxcompat' # generated by msbuild, should have it for ninja?
   else
     ldflags += '-Wl,--stack,@0@'.format(cdata.get('WIN32_STACK_RLIMIT'))

It's not quite the way meson wants you to do it (declare it in
default_options), but with our minimum meson version that's just a single
option, not a list...

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Reject Windows command lines not convertible to system locale
Next
From: Andres Freund
Date:
Subject: Re: pg_attribute_noreturn(), MSVC, C11