[llvm-dev] problem (and fix) with -fms-extensions
Marc Espie via llvm-dev
llvm-dev at lists.llvm.org
Thu May 11 11:04:06 PDT 2017
I've tried to build something that wanted ms-extensions on OpenBSD.
Long story short, didn't work so well, because all system includes
lead to
<machine/_types.h>
#ifndef __cplusplus
typedef int __wchar_t;
#endif
and since ms-extensions includes __char_t as a built-in, this did fail
abysmally.
It would be simple to fix in OpenBSD, assuming clang did tell us it
was using ms-extensions.
Would something like this be appropriate ? macro name subject to approval
of course.
Index: lib/Frontend/InitPreprocessor.cpp
===================================================================
RCS file: /build/data/openbsd/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
--- lib/Frontend/InitPreprocessor.cpp 14 Mar 2017 08:07:56 -0000 1.1.1.4
+++ lib/Frontend/InitPreprocessor.cpp 11 May 2017 17:54:41 -0000
@@ -366,6 +366,8 @@ static void InitializeStandardPredefined
else
Builder.defineMacro("__STDC_HOSTED__");
+ if (LangOpts.MicrosoftMode)
+ Builder.defineMacro("__ms_extensions__", 1);
if (!LangOpts.CPlusPlus) {
if (LangOpts.C11)
Builder.defineMacro("__STDC_VERSION__", "201112L");
-------------- next part --------------
Index: lib/Frontend/InitPreprocessor.cpp
===================================================================
RCS file: /build/data/openbsd/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
--- lib/Frontend/InitPreprocessor.cpp 14 Mar 2017 08:07:56 -0000 1.1.1.4
+++ lib/Frontend/InitPreprocessor.cpp 11 May 2017 17:54:41 -0000
@@ -366,6 +366,8 @@ static void InitializeStandardPredefined
else
Builder.defineMacro("__STDC_HOSTED__");
+ if (LangOpts.MicrosoftMode)
+ Builder.defineMacro("__ms_extensions__", 1);
if (!LangOpts.CPlusPlus) {
if (LangOpts.C11)
Builder.defineMacro("__STDC_VERSION__", "201112L");
More information about the llvm-dev
mailing list