[cfe-commits] [PATCH] -fshort-wchar

Douglas Gregor dgregor at apple.com
Thu Nov 5 08:54:03 PST 2009


On Nov 5, 2009, at 8:30 AM, John Thompson wrote:

> Or maybe something that combines the two test scheme with my  
> original change:
>
> // RUN: clang-cc %s -fsyntax-only -verify &&
> // RUN: clang-cc %s -fsyntax-only -fshort-wchar -verify -DSHORT_WCHAR"
>
> #include <wchar.h>
>
> #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \\
>  || defined(_M_X64) || defined(SHORT_WCHAR)
>   #define WCHAR_T_TYPE unsigned short
> #else
>   #define WCHAR_T_TYPE int
> #endif
>
> int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1];
>
> void foo() {
>   WCHAR_T_TYPE t1[] = L"x";
>   wchar_t tab[] = L"x";
>   WCHAR_T_TYPE t2[] = "x";     // expected-error {{initialization}}
>   char t3[] = L"x";   // expected-error {{initialization}}
> }
> You don't get the complete platform-independence, but it avoids the  
> include problems with specifying a triple, and still tests -fshort- 
> wchar, but only on non-windows platforms.

I like this one a lot. Thank you!

   - Doug



More information about the cfe-commits mailing list