在objective-c中使用c++类。

时间:2022-12-09 18:51:42

Basically I have 2 source files like following in my workspace:

基本上我有两个源文件在我的工作空间如下:

vectormath_aos.h

vectormath_aos.h

#ifndef _VECTORMATH_AOS_CPP_SCALAR_H
#define _VECTORMATH_AOS_CPP_SCALAR_H

#include <math.h>

#ifdef _VECTORMATH_DEBUG
#include <stdio.h>
#endif

namespace Vectormath {

namespace Aos {

//-----------------------------------------------------------------------------
// Forward Declarations
//

class Vector3;
class Vector4;
class Point3;
class Quat;
class Matrix3;
class Matrix4;
class Transform3;
...

exampleopenglesViewController.mm

exampleopenglesViewController.mm

#import <QuartzCore/QuartzCore.h>

#import "exampleopenglesViewController.h"
#import "EAGLView.h"
#import "vectormath_aos.h"

Matrix4 mvpmatrix;
...

However, when I try to run the project in Xcode 4.0, it always give me the error: Unknown type name "Matrix4". I am really confused because it used to work for me when I was working on Xcode 3.2. Anyone knows what goes wrong here? Thanks in advance!:)

但是,当我尝试在Xcode 4.0中运行项目时,总是会出现错误:未知类型名“Matrix4”。我真的很困惑,因为当我在Xcode 3.2上工作时,它曾经为我工作。有人知道这里出了什么问题吗?提前谢谢!)

1 个解决方案

#1


4  

Since you’re using namespaces,

因为你正在使用名称空间,

Matrix4 mvpmatrix;

should be:

应该是:

Vectormath::Aos::Matrix4 mvpmatrix;

instead.

代替。

#1


4  

Since you’re using namespaces,

因为你正在使用名称空间,

Matrix4 mvpmatrix;

should be:

应该是:

Vectormath::Aos::Matrix4 mvpmatrix;

instead.

代替。