2011-05-27 68 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; 

代替。