[cfe-dev] [llvm-dev] problem (and fix) with -fms-extensions
Marc Espie via cfe-dev
cfe-dev at lists.llvm.org
Sat May 13 09:02:48 PDT 2017
On Fri, May 12, 2017 at 08:53:53AM -0700, Reid Kleckner wrote:
>
> Moving to cfe-dev to discuss clang things.
> I think we already have _WCHAR_T_DEFINED for this:
> Â if (LangOpts.MicrosoftExt) {
> Â Â if (LangOpts.WChar) {
> Â Â Â // wchar_t supported as a keyword.
> Â Â Â Builder.defineMacro("_WCHAR_T_DEFINED");
> Â Â Â Builder.defineMacro("_NATIVE_WCHAR_T_DEFINED");
> Â Â }
> Â }
Nope. I'm talking about the __wchar_t type.
In my case, even a C language "hello world" won't compile:
nausicaa$ clang -fms-extensions a.c
In file included from a.c:1:
In file included from /usr/include/stdio.h:43:
In file included from /usr/include/sys/_types.h:37:
/usr/include/machine/_types.h:132:15: error: cannot combine with previous 'int'
declaration specifier
typedef int __wchar_t;
^
1 error generated.
but actually based on the existing code, I would suggest following
the pattern.
my main concern would be: are names with ___ readable, or is there
a suggestion for better names ?
Index: InitPreprocessor.cpp
===================================================================
RCS file: /cvs/src/gnu/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp,v
retrieving revision 1.1.1.4
diff -u -p -r1.1.1.4 InitPreprocessor.cpp
--- InitPreprocessor.cpp 14 Mar 2017 08:07:56 -0000 1.1.1.4
+++ InitPreprocessor.cpp 13 May 2017 15:59:14 -0000
@@ -666,6 +668,10 @@ static void InitializePredefinedMacros(c
// wchar_t supported as a keyword.
Builder.defineMacro("_WCHAR_T_DEFINED");
Builder.defineMacro("_NATIVE_WCHAR_T_DEFINED");
+ } else {
+ // __wchar_t supported as a keyword
+ Builder.defineMacro("___WCHAR_T_DEFINED");
+ Builder.defineMacro("_NATIVE___WCHAR_T_DEFINED");
}
}
More information about the cfe-dev
mailing list