gpt4 book ai didi

mingw - Clang 通过命令行工作,但不能通过 SublimeClang (Win8x64) 在 Sublime Text 中工作

转载 作者:行者123 更新时间:2023-12-01 10:54:24 31 4
gpt4 key购买 nike

使用 MinGW 4.7.0,MSYS 编译的 Clang 3.2。

我通过自动安装程序/下载程序获得了 MinGW,并按照以下说明构建了 Clang:http://bencode.net/clangonwindows


在 PowerShell 上调用“g++ --version”返回:在此处输入代码

在 PowerShell 上调用“clang -v”返回:clang version 3.2 (trunk 167353)
目标:i686-pc-mingw32
线程模型:posix


我创建了一个小测试文件来检查 clang 是否正常工作,“test.cpp”:

#include <iostream>

class clangIsCool
{
public:
int x;
int y;
};

int main()
{
clangIsCool *c;
std::cout << c->x * 10;

return 0;
}

调用“clang++ test.cpp”没有出现错误。


然后我使用包控制为 SublimeText2 获取了 SublimeClang。

SublimeClang 可以在这里找到:https://github.com/quarnster/SublimeClang

在 SublimeText2 中加载“test.cpp”并尝试编译时出现以下错误:

C:/MinGW/include\wctype.h:99,33 - Error - definition of variable with array type needs an explicit size or an initializer
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\cwchar:145,11 - Error - no member named 'fgetws' in the global namespace
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\cwchar:147,11 - Error - no member named 'fputws' in the global namespace
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\cwchar:151,11 - Error - no member named 'getwc' in the global namespace
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\cwchar:152,11 - Error - no member named 'getwchar' in the global namespace
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\cwchar:157,11 - Error - no member named 'putwc' in the global namespace
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\cwchar:158,11 - Error - no member named 'putwchar' in the global namespace
C:/MinGW/include\ctype.h:112,33 - Error - redefinition of '_ctype'
C:/MinGW/include\ctype.h:112,33 - Error - definition of variable with array type needs an explicit size or an initializer
C:/MinGW/include\ctype.h:117,34 - Error - redefinition of '_pctype_dll'

我检查了 SublimeClang 的设置,这是 clang 使用的选项:

"options":
[
"-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/",
"-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1",
"-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/",
"-isystem", "C:\\MinGW\\lib\\gcc\\mingw32\\4.7.0\\include",
"-isystem", "C:\\MinGW\\lib\\gcc\\mingw32\\4.7.0\\include\\c++",
"-isystem", "C:\\MinGW\\lib\\gcc\\mingw32\\4.7.0\\include\\c++\\mingw32",
"-isystem", "C:\\MinGW\\include",
"-Wall"
],

我试着弄乱包含路径(即使它们对我来说看起来是正确的),但错误仍然存​​在。

我应该在 SublimeClang 的选项中包含任何其他路径吗?

有没有办法查看 clang 默认使用的路径(因为它在命令行中工作),以便我可以将它们与 SublimeClang 默认使用的路径进行比较?

最佳答案

我从 #include <iostream> 得到了同样的错误,我能够通过定义 __GNUC__=4 来阻止它们, __GNUC_MINOR__=7 (显然,这是针对 GCC 4.7 的)和 __MSVCRT__=1 .

不幸的是,#include <vector>给我一大堆其他错误:

C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\bits/alloc_traits.h:56,35 - Error - in-class initializer for static data member is not a constant expression
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\bits/alloc_traits.h:86,24 - Error - type 'int' cannot be used prior to '::' because it has no members
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\ext/alloc_traits.h:105,11 - Error - using declaration refers into '_Base_type::', which is not a base class of '__alloc_traits<int>'
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\ext/alloc_traits.h:106,11 - Error - using declaration refers into '_Base_type::', which is not a base class of '__alloc_traits<int>'
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\ext/alloc_traits.h:107,11 - Error - using declaration refers into '_Base_type::', which is not a base class of '__alloc_traits<int>'
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\ext/alloc_traits.h:108,11 - Error - using declaration refers into '_Base_type::', which is not a base class of '__alloc_traits<int>'
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\ext/alloc_traits.h:109,11 - Error - using declaration refers into '_Base_type::', which is not a base class of '__alloc_traits<int>'
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\bits/stl_vector.h:81,16 - Error - base specifier must name a class
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\bits/stl_vector.h:235,13 - Error - using declaration refers into '_Base::', which is not a base class of 'vector<int, std::allocator<int> >'
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\bits/stl_vector.h:236,13 - Error - using declaration refers into '_Base::', which is not a base class of 'vector<int, std::allocator<int> >'
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\bits/stl_vector.h:237,13 - Error - using declaration refers into '_Base::', which is not a base class of 'vector<int, std::allocator<int> >'
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\bits/stl_vector.h:238,13 - Error - using declaration refers into '_Base::', which is not a base class of 'vector<int, std::allocator<int> >'
C:/MinGW/lib/gcc/mingw32/4.7.0/include/c++\bits/stl_vector.h:527,13 - Error - using declaration refers into '_Base::', which is not a base class of 'vector<int, std::allocator<int> >'

我只能假设这也是由于更多的缺失或错误的定义。但是,我尝试添加 g++ 提供的每个定义 ( http://stackoverflow.org/wiki/What_are_the_default_defines_in_my_Gnu_compiler? ),但它似乎没有任何效果(除了添加大量宏重新定义警告之外)。

我的SublimeClang项目设置如下(默认设置不变):

"sublimeclang_additional_language_options":
{
"c++" : ["-std=c++11"]
},

"sublimeclang_options":
[
"-D__GNUC__=4",
"-D__GNUC_MINOR__=7",
"-D__MSVCRT__=1",
"-IC:\\project-specific-source",
"-IC:\\project-specific-library\\include",
"-isystem", "C:\\MinGW\\lib\\gcc\\mingw32\\4.7.0\\include",
"-isystem", "C:\\MinGW\\lib\\gcc\\mingw32\\4.7.0\\include\\c++",
"-isystem", "C:\\MinGW\\lib\\gcc\\mingw32\\4.7.0\\include\\c++\\mingw32",
"-isystem", "C:\\MinGW\\include",
"-Wall",
"-ferror-limit=0"
]

关于mingw - Clang 通过命令行工作,但不能通过 SublimeClang (Win8x64) 在 Sublime Text 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13209891/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com