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?
Compiler supportVisual Studio 2019 supports all C++20 features through its /std:c++latest option, as of version 16.10. 0. An option /std:c++20 to enable C++20 mode is added in version 16.11. 0.
Is MinGW (MinGW-64) better than Cygwin in terms of MSVC alternative for creating Windows application? If your program will run only on Windows, then MinGW is likely the better choice. MinGW is designed to create Windows applications. It doesn't require users to install additional software to run your application.
Microsoft Visual C++ Microsoft Visual C++ (MSVC) is a compiler for the C, C++ and C++/CX programming languages by Microsoft. MSVC is proprietary software; it was originally a standalone product but later became a part of Visual Studio and made available in both trialware and freeware forms.
Microsoft C++ Compiler (MSVC) This is the default compiler for most Visual Studio C++ projects and is recommended if you are targeting Windows.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With