Skip to content

Force and assume that MSVC uses in C11 mode by default#52

Open
MisterDA wants to merge 2 commits intotrunkfrom
msvc-c11
Open

Force and assume that MSVC uses in C11 mode by default#52
MisterDA wants to merge 2 commits intotrunkfrom
msvc-c11

Conversation

@MisterDA
Copy link
Owner

Autoconf, through the AC_PROG_CC macro (called by libtool's LT_INIT), tries to detect whether the C compiler needs options to enable C11 support (we require a C11 compiler).

Autoconf development branch now understand hows to enable MSVC C11 support (bug report, patch), which defaults to a C99 dialect. Note that clang-cl defaults to C17.

It would be unfair to use Autoconf tests for missing or buggy C11 features if MSVC is in C99 mode, so we have to add -std:c11 or -std:c17 to CFLAGS.

We can already re-organize our tests to assume C11, and, until Autoconf 2.73 is used, we can enable MSVC' C11 support by default. As it is still possible for the user to mess up the CFLAGS, we can keep a convenience fallback re-enabling C11 in case it was disabled. I'm tempted to remove this fallback altogether (for instance, if the user inadvertently disables C11, Autoconf tests will use the C99 compiler until the fallback re-enabling C11 is reached…).

The first and last commit should be reverted once we'll use Autoconf 2.73.

No change entry needed.

@MisterDA MisterDA force-pushed the msvc-c11 branch 3 times, most recently from 765a4a4 to e14a277 Compare May 22, 2024 09:40
MisterDA added 2 commits May 22, 2024 11:45
Autoconf, through the [`AC_PROG_CC`][] macro (called by libtool's
[`LT_INIT`][]), tries to detect whether the C compiler needs options
to enable C11 support (we require a C11 compiler).

Autoconf development branch now understand hows to enable MSVC C11
support ([bug report][1], [patch][2]), which defaults to a C99
dialect. The code to detect C11 has also been fixed in the dev branch.
We may use ac_prog_cc_stdc when Autoconf 2.73 is released. Note that
clang-cl defaults to C17.

It would be unfair to use Autoconf tests for missing or buggy C11
features if MSVC is in C99 mode, so we have to add `-std:c11` or
`-std:c17` to `CFLAGS`. Our Autoconf tests can now expect a C11
compiler by default.

The best-effort MSVC handling code can be removed once we switch to
Autoconf 2.73. It works even if the user overwrites the `CFLAGS`,
potentially disabling C11.

[`AC_PROG_CC`]: https://www.gnu.org/software/autoconf/manual/autoconf-2.72/html_node/C-Compiler.html#index-AC_005fPROG_0
05fCC-1
[`LT_INIT`]: https://www.gnu.org/software/libtool/manual/html_node/LT_005fINIT.html
[1]: https://lists.gnu.org/archive/html/autoconf/2024-04/msg00001.html
[2]: http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commit;h=e9fee73dba5d2156abc48734b5a9faff89dcdc11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant