与 MinGW STL 的 Clang (错误:全局命名空间中没有名为 'fgetws' 的成员)
Clang with MinGW STL (Error: no member named 'fgetws' in the global namespace)
我试图在windows下使用MinGW STL (Clang和MinGW的最新版本)编译一个简单的dll。正如你所看到的,我已经禁用了ms兼容模式和硬编码的VS头文件。当我包含MinGW STL映射头时,我得到以下错误:
C:Program Files (x86)LLVMvc11binDebug>clang++ -fno-ms-compatibility -nostdinc -c -shared -v -o simple.o simple.cpp -I "C:MinGWincludesys" -I "C:MinGWlibgcci686-pc-mingw324.8.0include" -I "C:MinGWinclude" -I "C:MinGWincludec++" -I "C:MinGWincludec++4.8.0" -I "C:MinGWincludec++4.8.0backward" -I "C:MinGWincludec++4.8.0bits" -I "C:MinGWincludec++4.8.0debug" -I "C:MinGWincludec++4.8.0decimal" -I "C:MinGWincludec++4.8.0ext" -I "C:MinGWincludec++4.8.0i686-pc-mingw32" -I "C:MinGWincludec++4.8.0tr1" -I "C:MinGWincludec++4.8.0tr2" -I "C:MinGWincludec++4.8.0profile" -Wl,--verbose
clang version 3.4 (trunk)
Target: i686-pc-win32
Thread model: posix
clang++.exe: warning: -Wl,--verbose: 'linker' input unused
clang++.exe: warning: argument unused during compilation: '-shared'
"C:/Program Files (x86)/LLVM/vc11/bin/Debug/clang++.exe" -cc1 -triple i686-pc-win32 -emit-obj -mrelax-all -disable-free -main-file-name simple.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -v -coverage-file simple.o -nostdsysteminc -nobuiltininc -resource-dir "C:/Program Files (x86)/LLVM/vc11/bin/Debug\..\lib\clang\3.4" -I "C:\MinGW\include\sys" -I "C:\MinGW\lib\gcc\i686-pc-mingw32\4.8.0\include" -I "C:\MinGW\include" -I "C:\MinGW\include\c++" -I "C:\MinGW\include\c++\4.8.0" -I "C:\MinGW\include\c++\4.8.0\backward" -I "C:\MinGW\include\c++\4.8.0\bits" -I "C:\MinGW\include\c++\4.8.0\debug" -I "C:\MinGW\include\c++\4.8.0\decimal" -I "C:\MinGW\include\c++\4.8.0\ext" -I "C:\MinGW\include\c++\4.8.0\i686-pc-mingw32" -I "C:\MinGW\include\c++\4.8.0\tr1" -I "C:\MinGW\include\c++\4.8.0\tr2" -I "C:\MinGW\include\c++\4.8.0\profile" -std=c++11 -fdeprecated-macro -ferror-limit 19 -fmessage-length 150 -mstackrealign -fms-extensions -fmsc-version=1300 -fdelayed-template-parsing -fobjc-runtime=gcc -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o simple.o -x c++ simple.cpp
clang -cc1 version 3.4 based upon LLVM 3.4svn default target i686-pc-win32
#include "..." search starts here:
#include <...> search starts here:
C:MinGWincludesys
C:MinGWlibgcci686-pc-mingw324.8.0include
C:MinGWinclude
C:MinGWincludec++
C:MinGWincludec++4.8.0
C:MinGWincludec++4.8.0backward
C:MinGWincludec++4.8.0bits
C:MinGWincludec++4.8.0debug
C:MinGWincludec++4.8.0decimal
C:MinGWincludec++4.8.0ext
C:MinGWincludec++4.8.0i686-pc-mingw32
C:MinGWincludec++4.8.0tr1
C:MinGWincludec++4.8.0tr2
C:MinGWincludec++4.8.0profile
End of search list.
In file included from simple.cpp:3:
In file included from C:MinGWincludec++4.8.0map:61:
In file included from C:MinGWincludec++4.8.0bits/stl_map.h:63:
In file included from C:MinGWincludec++4.8.0tuple:39:
In file included from C:MinGWincludec++4.8.0array:38:
In file included from C:MinGWincludec++4.8.0stdexcept:39:
In file included from C:MinGWincludec++4.8.0string:40:
In file included from C:MinGWincludec++4.8.0bits/char_traits.h:40:
In file included from C:MinGWincludec++4.8.0bits/postypes.h:40:
C:MinGWincludec++4.8.0cwchar:143:11: error: no member named 'fgetws' in the global namespace
using ::fgetws;
~~^
C:MinGWincludec++4.8.0cwchar:145:11: error: no member named 'fputws' in the global namespace
using ::fputws;
~~^
C:MinGWincludec++4.8.0cwchar:149:11: error: no member named 'getwc' in the global namespace
using ::getwc;
~~^
C:MinGWincludec++4.8.0cwchar:150:11: error: no member named 'getwchar' in the global namespace
using ::getwchar;
~~^
C:MinGWincludec++4.8.0cwchar:155:11: error: no member named 'putwc' in the global namespace
using ::putwc;
~~^
C:MinGWincludec++4.8.0cwchar:156:11: error: no member named 'putwchar' in the global namespace
using ::putwchar;
~~^
6 errors generated.
任何帮助都是感激的!
这些函数在定义__MSVCRT__
宏时在MinGW的stdio.h
和/或wchar.h
中声明。MinGW编译器在构建msvcrt.dll
运行时而不是旧的crtdll
运行时(我认为几乎从未使用过)定义__MSVCRT__
。
我不知道clang是否会定义这个宏,或者在什么条件下它会定义(甚至clang是否会链接到msvcrt.dll
)。
您可以尝试在clang命令行中添加-D__MSVCRT__=1
,看看是否可以正常工作。
相关文章:
- 将成员变量添加到共享库中的类中,不会破坏二进制兼容性吗
- 对RValue对象调用的LValue ref限定成员函数
- 为什么使用 "this" 指针调用派生成员函数?
- 具有奇怪重复模板模式的派生类中的成员变量已损坏
- 助记符和指向成员语法的指针
- 用于访问容器<T>数据成员的正确 API
- 内置函数可查看CPP中的成员变量
- 是否可以初始化不可复制类型的成员变量(或基类)
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 嵌套在类中时无法设置成员数据
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 将函数类成员映射到类本身内部
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- 将Ref对象作为类成员
- 将包含C样式数组的对象初始化为成员变量(C++)
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 将公共但非静态的成员函数与ALGLIB集成
- 多成员Constexpr结构初始化
- 与 MinGW STL 的 Clang (错误:全局命名空间中没有名为 'fgetws' 的成员)