在编译时编译Xcode中的C类错误:stl vector

我有一个C类,用 gcc和可视化工作室中的寡妇在 linux上编译.

boid.h:

#ifndef BOID_CLASS_HEADER_DEFInes_H
#define BOID_CLASS_HEADER_DEFInes_H
#include "defines.h"

class Boid {

public:
     // Initialize the boid with random position,heading direction and color
     Boid(float SceneRadius,float normalVel);

     .....
protected:
     ...
};

#endif

并在boid.cpp中:

#include "Boid.h"

// Initialize the boid with random position,heading direction and color
Boid::Boid(float SceneRadius,float normalVel) 
{
    ....
}

但是,当我在Xcode中编译此代码时,我收到以下错误

Compiling Boid.h: "error: vector: No such file or directory"

有任何想法吗?我以为你可以使用C/C++代码并在Xcode中编译没有问题?

谢谢

编辑:添加了define.h(也添加了#endif样本,但是在原始代码中)

编辑2:我有一个不同的错误后,注释掉几个包括有空:上面的向量错误.

#ifndef BOID_NAV_DEFInes_H
#define BOID_NAV_DEFInes_H
#include <stdlib.h>
#include <vector>
#include "Vector3d.h"
#include "Point3d.h"
#include "win_layer.h"
#endif

解决方法

您是否将C头包括在.m文件中?

.m文件被视为具有Objective-C扩展名的.c文件.

.mm文件被视为具有Objective-C扩展名的.cpp文件,那么它被称为Objective-C

只需将.m文件重命名为.mm,右键单击或按住Ctrl键并在Xcode中的文件中选择重命名.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...