2012-08-15 44 views
2

我想在OS X 10.7下使用clang ++編譯VCMIC++錯誤:'內聯'只能出現在函數上

我配置了CXX=clang++的項目,因爲蘋果的gcc似乎沒有認出所需的-std=c++0x標誌。

我添加了-stdlib=libc++CXXFLAGS,因爲沒有那個鏗鏘聲甚至沒有找到#include <array>

目前我已經有了:CXXFLAGS= -std=c++0x -stdlib=libc++ -Wall -Wextra -Wcast-align -Wpointer-arith -Wno-switch -Wno-sign-compare -Wno-unused-parameter -Wc++11-extensions

的問題是,我收到以下錯誤:

clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated 
clang: warning: argument unused during compilation: '-ggdb' 
StdInc.h:1:9: warning: #pragma once in main file 
#pragma once 
     ^
In file included from StdInc.h:3: 
In file included from ./../Global.h:32: 
In file included from /usr/bin/../lib/c++/v1/algorithm:594: 
In file included from /usr/bin/../lib/c++/v1/memory:596: 
/usr/bin/../lib/c++/v1/iterator:1696:1: error: 'inline' can only appear on functions 
inline _LIBCPP_INLINE_VISIBILITY 
^ 
/usr/bin/../lib/c++/v1/iterator:1698:1: error: variable 'begin' declared as a template 
begin(_T (&__array)[_N]) 
^ 
/usr/bin/../lib/c++/v1/iterator:1698:12: error: use of undeclared identifier '__array' 
begin(_T (&__array)[_N]) 
     ^
./../tchar_amigaos4.h:157:16: note: expanded from macro '_T' 
#define _T(x)   x 
         ^
In file included from StdInc.h:3: 
In file included from ./../Global.h:32: 
In file included from /usr/bin/../lib/c++/v1/algorithm:594: 
In file included from /usr/bin/../lib/c++/v1/memory:596: 
/usr/bin/../lib/c++/v1/iterator:1698:25: error: expected ';' at end of declaration 
begin(_T (&__array)[_N]) 
         ^
         ; 
/usr/bin/../lib/c++/v1/iterator:1699:1: error: expected unqualified-id 
{ 
^ 
1 warning and 5 errors generated. 

我必須承認,我從來沒有見過這樣的事。這些都在libC++源代碼中! 有人知道可能是什麼原因嗎?

+0

你是否已經驗證了源代碼包含在std lib頭文件後? – justin 2012-08-15 13:22:54

回答

5

你的問題就在這裏:

./../tchar_amigaos4.h:157:16: note: expanded from macro '_T' 
#define _T(x)   x 

定義一個名爲_T宏在你的代碼,然後包括標準的頭,是不確定的行爲,嚴格地說。

IIRC,較新版本的libC++避免使用名稱_T,特別是因爲人們傾向於這樣做,所以您可能想嘗試升級到最新版本的命令行工具。