[cfe-dev] [llvm-dev] problem (and fix) with -fms-extensions
Reid Kleckner via cfe-dev
cfe-dev at lists.llvm.org
Wed May 17 13:01:07 PDT 2017
I'd rather not add new pre-defined macros if we can avoid it. There are
already too many. You can probably detect this situation with:
#if defined(_MSC_EXTENSIONS) && !defined(_WCHAR_T_DEFINED)
On Sat, May 13, 2017 at 9:02 AM, Marc Espie <espie at nerim.net> wrote:
> 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");
> }
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170517/5f30f121/attachment.html>
More information about the cfe-dev
mailing list