Brian
Brian

Reputation: 745

use c++ class in objective-c

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

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;
...

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!:)

Upvotes: 3

Views: 504

Answers (1)

user557219
user557219

Reputation:

Since you’re using namespaces,

Matrix4 mvpmatrix;

should be:

Vectormath::Aos::Matrix4 mvpmatrix;

instead.

Upvotes: 4

Related Questions