Re: C11 / VS 2019
От | Peter Eisentraut |
---|---|
Тема | Re: C11 / VS 2019 |
Дата | |
Msg-id | ccb273c9-7544-4748-8638-30feba212e6e@eisentraut.org обсуждение исходный текст |
Ответ на | C11 / VS 2019 (Peter Eisentraut <peter@eisentraut.org>) |
Ответы |
Re: C11 / VS 2019
|
Список | pgsql-hackers |
Ok, now that we have seemingly stabilized the VS 2019 upgrade, here is the next patch set to actually raise the compiler requirement to C11. Viewed from very far away, this just adjusts the existing places that say C99 and replaces them with a C11 analogue. The details are a bit of a longer story. configure.ac previously used AC_PROG_CC_C99 to activate C99. But there is no AC_PROG_CC_C11 in Autoconf 2.69, because it's too old. Also, post-2.69, the AC_PROG_CC_Cnn macros were deprecated and AC_PROG_CC activates the last supported C mode. So, at this point, we could "just" update the Autoconf version requirement. But somehow I don't feel like doing that, as it's just another non-trivial project to negotiate. Instead, I just hand-coded some test for C11 using some inspiration from later Autoconf versions. But instead of writing an elaborate test program that exercises many different features, I kept it simple and just check __STDC_VERSION__, which should be good enough in practice. (If someone later wanted to update the Autoconf version, they could just delete that code again.) In meson.build, there is an existing hand-coded C99 test that I update to C11, but again just checking for __STDC_VERSION__. I also moved the test a bit earlier in meson.build, as a separate patch, because between the place where the compiler is first set up and the place where we detected the C99 options, if any, there were already some tests run that use the compiler. I don't think this was a big problem in practice, but it seems a bit incorrect, so it makes sense to correct it. Note, we don't use the "official" way to set the C standard in Meson using the c_std project option, because that is IMO impossible to use correctly (see <https://github.com/mesonbuild/meson/issues/14717>). (Well, that is my reason now. I don't know what the reason was previously.) The disadvantage is that meson will complain like meson.build:3013: WARNING: Consider using the built-in option for language standard version instead of using "/std:c11". But you will get warnings from meson with MSVC anyway, so, uh, another one will not make a significant difference. (Also, this issue exists with the existing C99 detection code as well, except that in practice you don't need an option, so the warning does not appear.) Note that gcc and clang switched to C11 by default a long time ago (gcc-5 and clang-3.6), so for most users all these tests won't need to do anything. If you want to test it, you could simulate an older default like ./configure CC='gcc -std=c99' and then the test should decide that it needs to add another option to override the C mode.
Вложения
В списке pgsql-hackers по дате отправления: