[cfe-dev] Enabling/disabling support for wchar_t type.

Enea Zaffanella zaffanella at cs.unipr.it
Fri Aug 31 03:09:10 PDT 2012


Hello.

According to language standards, the wchar_t type is
   - a library provided type in C
   - a native type in C++.

There are C++ compilers allowing users to enable/disable the native 
support. For instance, MSVC has option /Zc:wchar_t. Even though the 
default in newer versions of MSVC is to enable wchar_t support, there is 
much code in the real world that will only work if this is disabled
(e.g., Qt X.Y.Z with X < 5).

The attached simple patch adds flag WChar to LangOptions.
The flag is similar to Bool: if set, the native wchar_t type is 
supported (i.e., wchar_t will be lexed as a keyword), otherwise it won't 
be supported (i.e., it will be a normal identifier). Currently, the flag 
is initialized the same as CPlusPlus, so that the addition should cause 
no visible change.

The addition of this flag will be enough for people using clang as a set 
of libraries. For more "conventional" uses, it might be worth 
considering the addition of a suitable command line option to toggle the 
flag.

Opinions?

Enea.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WChar.patch
Type: text/x-diff
Size: 4016 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120831/a9ba074f/attachment.patch>


More information about the cfe-dev mailing list