Re: pg_attribute_noreturn(), MSVC, C11
От | Peter Eisentraut |
---|---|
Тема | Re: pg_attribute_noreturn(), MSVC, C11 |
Дата | |
Msg-id | 207cba7e-35fe-4309-a128-b53f7e21cc29@eisentraut.org обсуждение исходный текст |
Ответ на | pg_attribute_noreturn(), MSVC, C11 (Andres Freund <andres@anarazel.de>) |
Ответы |
Re: pg_attribute_noreturn(), MSVC, C11
|
Список | pgsql-hackers |
On 13.12.24 20:10, Andres Freund wrote: > C11 has been out a while, so I'm somewhat inclined to adopt _Noreturn/noreturn > in a conditional way. Older compilers would still work, just not understand > noreturn. > > One wrinkle: _Noreturn/noreturn have been deprecated in C23, because that > adopted C++11's attribute syntax (i.e. [[noreturn]]). But that's at least in > the same place as _Noreturn/return. > > We can't remove [[noreturn]] with preprocessor magic, so it's not really > viable to use that for, uhm, quite a while. > > If we were to use _Noreturn, I think it could just be something like: > > I think it should suffice to do something like > > #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L > #define pg_noreturn _Noreturn > #else > #define pg_noreturn > #endif This looks reasonable to me. We also have pg_nodiscard. (That's got a slightly different history in the C standard, but I mean it's also "pg_someattribute".) > (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.
В списке pgsql-hackers по дате отправления: