In C++20 u8
string literals are based on the char8_t
type. They deliberately do not convert to char const*
any more:
const char* str = u8"Hall\u00f6chen \u2603"; // no longer valid in C++20
Of course, the ultimate goal when migrating to C++20 is to entirely go with the new behaviour (in the example above: change the type of str
). However, because of 3rd party libraries, this is often not possible immediately.
The proposals that introduce and "remedy" char8_t
anticipate that and mention that in clang and gcc there is the -fno-char8_t
flag to switch back to the old behaviour (while still being able to enjoy other C++20 features).
The 2nd proposal sets up the expectation that Microsoft will follow and add a similar flag, but I was not able to find how to set it (at least in VS 2019, Version 16.4).
So does anyone know what the MSVC equivalent for -fno-char8_t
is?
Since 16.1, there is the conformance compiler flag /Zc:char8_t-
. The minus tells the compiler to not use conformance mode here when using C++20. On the contrary, /Zc:char8_t
can be used to enable it.