Xcode 在已经有标头调用STL的源中包含STL

Xcode 在已经有标头调用STL的源中包含STL,xcode,macos,stl,vector,artoolkit,Xcode,Macos,Stl,Vector,Artoolkit,我正在Mac OS X Lion上运行ARtoolkit(根据ARtoolkit说明,使用SDK 10.5),并希望包含矢量库 然而,我似乎无法做到这一点,也不明白为什么。起初我认为这是使用旧SDK的工具包的问题,但在深入研究时,我发现stl_vector.h在某一点上被包括在内,当我包括vector(或stl_vector)时,我收到了大量的错误消息 有什么办法可以让我使用向量吗 以下是我的包含路径: #ifdef _WIN32 # include <windows.h> #en

我正在Mac OS X Lion上运行ARtoolkit(根据ARtoolkit说明,使用SDK 10.5),并希望包含矢量库

然而,我似乎无法做到这一点,也不明白为什么。起初我认为这是使用旧SDK的工具包的问题,但在深入研究时,我发现stl_vector.h在某一点上被包括在内,当我包括vector(或stl_vector)时,我收到了大量的错误消息

有什么办法可以让我使用向量吗

以下是我的包含路径:

#ifdef _WIN32
#  include <windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#ifndef __APPLE__
#  include <GL/glut.h>
#else
#  include <GLUT/glut.h>
#endif

#include <AR/gsub.h>
#include <AR/param.h>
#include <AR/ar.h>
#include <AR/video.h>

#include <time.h>
#include "object.h"

#include <vector>

using namespace std;
\ifdef\u WIN32
#包括
#恩迪夫
#包括
#包括
#包括
#包括
#苹果__
#包括
#否则
#包括
#恩迪夫
#包括
#包括
#包括
#包括
#包括
#包括“object.h”
#包括
使用名称空间std;
以下是我看到的错误

/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
/Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.2.1/bits/allocator.h
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/bits/stl_bvector.h
Expected template-name before '<' token
Expected `{' before '<' token
Expected unqualified-id before '<' token
/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/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_vector.h
“分配器”之前应为类型说明符
“分配器”之前应为“>”
尚未声明“输入迭代器标记”
尚未声明“前进迭代器标记”
尚未声明“输入迭代器标记”
尚未声明“前进迭代器标记”
尚未声明“输入迭代器标记”
尚未声明“前进迭代器标记”
没有依赖于模板参数的“\u\N”参数,因此“\u\N”的声明必须可用
(如果您使用'-fppermissive',G++将接受您的代码,但不赞成使用未声明的名称)
“迭代器”之前应为嵌套名称说明符

“Ugh”之前应为初始值设定项。这让我更讨厌Xcode

为了解决这个问题,我首先将项目转换为C++(改名为*.CPP,只将编译模式设置为C++),然后将SDK升级到10.6(10.5原来是唯一的一个转换为C++)。


一旦这样做了,我就能够在没有任何问题的情况下包含vector。这最终只是一个SDK问题。

只是一个结构和几个不相关的宏。对于恼人的“
#include
”这样的问题,我通常会通过对有问题的.cpp/.c文件中的“
#include
”行重新排序来最终编译。除此之外,您可能必须使用“
”ifndef uuu STL uuu
;#define STL”(或等效项)来确保头在正确的源文件中只包含一次。