2011-05-27 101 views
3

基本上我有2个源文件等在我的工作区以下:使用C++类在目标c

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

#import <QuartzCore/QuartzCore.h> 

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

Matrix4 mvpmatrix; 
... 

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

+0

你有没有试过把建筑目标中的“编译源代码”属性改为Objective-C++? – Tudorizer 2011-05-27 09:27:01

+0

刚刚尝试过,它仍然给出相同的错误,:( – Brian 2011-05-27 09:32:52

+0

哎呀!我怎么能忘记命名空间!它已经有一段时间,从我上次使用C++ .: p,thx Bavarious! – Brian 2011-05-27 09:38:48

回答

4

由于您使用的命名空间,

Matrix4 mvpmatrix; 

应该是:

Vectormath::Aos::Matrix4 mvpmatrix; 

代替。