2012-03-28 35 views
0

但願這不是mac.stackexchange更相關的StackOverflow ...使用STL

我使用的ARToolKit爲增強現實項目,以使它的Mac下工作,我需要運行10.5 SDK。

我的問題是,我似乎無法包括任何STL頭文件...尤其是矢量。

是否有任何形式的包裝或解決方法,我可以使用?我基本上是直編譯的C代碼,並想利用一些STL框架的更好的功能,加快發展...


編輯:

在仔細檢查,它出現ARToolkit在包含路徑的某個位置包含std_vector。

錯誤片段:

Bits/c++allocator.h: No such file or directory 
Expected template-name before '<' token 
Expected `{' before '<' token 
Expected unqualified-id before '<' token 
/Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.2.1/iosfwd 
Bits/c++locale.h: No such file or directory 
Bits/c++io.h: No such file or directory 
/Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.2.1/bits/stl_algobase.h 
Bits/c++config.h: No such file or directory 
/Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.2.1/bits/stl_vector.h 
Expected type-specifier before 'allocator' 
Expected '>' before 'allocator' 
'input_iterator_tag' has not been declared 
'forward_iterator_tag' has not been declared 
'input_iterator_tag' has not been declared 
'forward_iterator_tag' has not been declared 
'input_iterator_tag' has not been declared 
'forward_iterator_tag' has not been declared 
There are no arguments to '__N' that depend on a template parameter, so a declaration of '__N' must be available 
(if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) 
Expected nested-name-specifier before 'iterator_traits' 
Expected initializer before '<' token 
There are no arguments to '_IterCategory' that depend on a template parameter, so a declaration of '_IterCategory' must be available 
Expected nested-name-specifier before 'iterator_traits' 
Expected initializer before '<' token 
There are no arguments to '_IterCategory' that depend on a template parameter, so a declaration of '_IterCategory' must be available 
Expected nested-name-specifier before 'iterator_traits' 
Expected initializer before '<' token 
There are no arguments to '_IterCategory' that depend on a template parameter, so a declaration of '_IterCategory' must be available 
/Users/espais/research/artoolkit/trunk/artoolkit/examples/newproject/newproject.cpp 
Expected `}' at end of input 
/Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.2.1/bits/stl_bvector.h 
Expected template-name before '<' token 
Expected `{' before '<' token 
Expected unqualified-id before '<' token 
+0

爲什麼不能包含STL頭文件?當你做什麼時會發生什麼? – 2012-03-28 06:42:05

+1

STL是C++標準庫的一部分。如果你正在編譯的是「基本上直的C代碼」,也許這可能是你的問題? ;) – jalf 2012-03-28 07:38:44

+0

真的......我希望我能以某種方式將編譯器切換到C++(目前只有選項是LLVM GCC 4.2和Apple LLVM編譯器3.0)。 – espais 2012-03-28 13:46:51

回答

0

基本上,有一些技巧必須在幕後完成。 我不得不更新我的本地SDK(原因是ARToolkit確實支持更新的版本,無論他們的文檔說什麼),然後STL庫工作。

0

你可能需要做的,而不是.m(Objective-C的),你的文件.mm文件(的Objective-C++)。

除此之外,#include <vector>不應該有任何問題。

+0

它實際上是一個.C文件。我希望我可以將編譯器切換到C++,但我所看到的只是列表中的gcc。 – espais 2012-03-28 13:45:50

+0

您可以進入項目構建設置並在GCC 4.2語言部分下,選擇'編譯源代碼'下的'C++'而不是'根據文件類型'。 – StilesCrisis 2012-03-28 13:54:50

+0

這是有效的,但是一旦我包含了矢量頭文件,我就會得到> 200錯誤... – espais 2012-03-28 15:14:50