2012-11-03 129 views
3

使用MinGW 4.7.0,MSYS編譯的Clang 3.2。Clang ++通過命令行工作,但不通過SublimeClang(Win8x64)工作SublimeText

我通過自動安裝/下載了MinGW的,並且內置鏘以下說明:http://bencode.net/clangonwindows


調用的 「g ++ - 版本」 上的PowerShell返回:enter code here

呼喚「鐺-v 「在PowerShell會返回:clang version 3.2 (trunk 167353) Target: i686-pc-mingw32 Thread model: posix


我創建了一個小測試文件,以檢查是否鐺是WO rking,「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」給了我沒有錯誤。


然後,我使用Package Control爲SublimeText2獲得了SublimeClang。

SublimeClang可以在這裏找到:https://github.com/quarnster/SublimeClang

加載「TEST.CPP」在SublimeText2並試圖編譯給了我這些錯誤:

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的設置,這就是選擇鐺正在使用:

"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" 
], 

我試圖弄亂與包含路徑(即使他們看起來正確,但我),但錯誤s直到保持。

SublimeClang的選項中是否還有其他路徑?

有沒有辦法查看clang默認使用哪些路徑(因爲它是從命令行運行的),以便我可以將它們與默認的SublimeClang進行比較?

回答

4

我正在從#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" 
] 
2

我有同樣的錯誤,那是因爲LLVM是用不同版本的MinGW + GCC的建造。我嘗試着自己建立叮噹聲,但它沒有幫助。 今天,我解決了這個由從這裏安裝MinGW的+ GCC:

http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-dw2-4.6-release/i686-w64-mingw32-gcc-dw2-4.6.3-2-release-win32_rubenvb.7z/download 

和鏗鏘這裏:。

http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/clang-3.2-release/i686-w64-mingw32-clang-3.2-release-win32_rubenvb.7z/download 

把一切都放在同一個文件夾,以便機器人G ++ .exe和鐺++ exe文件都在相同的bin文件夾並將該bin文件夾放入PATH中。

這是我現在的sublimeclang配置:

{ 
    "additional_language_options": 
    { 
     "c++" : ["-std=c++11", 
       "-ID:\\Apps\\mingw32-gcc-dw2-4.6.3-2-clang-3.2-win32\\i686-w64-mingw32\\include"] 
    }, 

    "options": 
    [ 
     "-g", 
     "-O2", 
     "-Wall", 
     "-Wextra" 
    ], 

    "debug_options": false, 

    "dont_prepend_clang_includes": true, 

    "analyzer_commandline": 
    [ 
     "clang.exe", 
     "--analyze", 
     "-o", 
     "-" 
    ] 
} 

-I部分是因爲dont_prepend_clang_includes需要。

相關問題