I tried to test the C23 code from ACCU23 presentation, but it doesn't work. Here's what I get in Visual Studio under std:clatest
switch:
struct
return type doesn't generate an error on line 1, but does generate on line 15.auto
doesn't work (line 13). IntelliSense shows <error-type>
instead of inferred type (screenshot in the end of line).constexpr
doesn't work (line 5).true
doesn't work (line 24), however bool
does work (line 21).nullptr
doesn't work (line 18).Is it OK it doesn't work? Or do I do something wrong? Maybe there are some other switches I need to power on?
The presentation is using gcc in conforming C23 mode.
C23 was finished as far as voting on technical stuff in summer 2022, meaning that non-profit compilers like gcc and clang had almost 2 and a half year until the formal ISO release in October 2024 to fix support for the most important features. They mostly managed, some features are still not supported.
So what did Microsoft do during those 2 and a half years? Well, the latest and greatest MSVC last got updated in year 2022 to finally support ISO 9899:1989/Amd1:1995.
Note that you have to compile with /Zc:__STDC__
or otherwise you still get non-conforming ISO C:1989 minus technical amendments.
There's other /Zc
options you can play with in case you want to get closer to something similar to older versions of the C language, like for example /Zc:preprocessor
meaning "yes pretty please I want a working preprocessor" Which, much like a keyboard and computer screen, is quite a handy tool to have when coding in C.
Or /Zc:auto
to get C++ auto, not quite the same thing as C23 auto. (Why you'd ever want to use either in C code beats me.)
You can also get it to compile according to potentially non-conforming subsets of other withdrawn ISO standards such as C11 or C17 by adding /std:c11
or /std:c17
.
/std:clatest
and /std:c17
is as of today's date the same thing.
Try out:
printf("%ld", __STDC_VERSION__);
With MSVC 19.40 (VS 17.10) /Zc:__STDC__ /std:clatest
I get 201710
.
bool
does not work without including stdbool.h
, which is correct behavior, so if you somehow got it working you might be compiling the code the wrong way.
error C2065: 'bool': undeclared identifier