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

John McCall rjmccall at apple.com
Tue Sep 4 10:47:24 PDT 2012


On Sep 2, 2012, at 11:02 PM, Enea Zaffanella wrote:
> Resending to cfe-commit.
> 
> On 08/31/2012 12:09 PM, Enea Zaffanella wrote:
>> 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?

Please add a -cc1 option to suppress native wchar_t;  I think -fno-wchar
would be sufficient.

John.




More information about the cfe-commits mailing list