Mahavir
Mahavir

Reputation: 781

How can i call function from .m file to .mm file in ios

I have function in .mm file.

I want to call that function from my Viewcontroller file .m. But it always gives me compiler error when i am try to import .h file of c function.

I have class file like.

OpenCV.h
OpenCV.mm

ViewController Class

ViewController.h
ViewController.m

Now when i am import OpenCV.h it gives me error. not able to compile

#import "OpenCV.h"  //Error Line
@implementation ViewController
@end

So how can i use .mm method in .m class

Error comes in OpenCV.h file

enter image description here

Upvotes: 2

Views: 1713

Answers (1)

Carl Norum
Carl Norum

Reputation: 224864

You can't do that - you're trying to compile an Objective-C++ header in an Objective-C context. You should just be able to change the name of ViewController.m to ViewController.mm to compiler it as Objective-C++ instead.

Upvotes: 2

Related Questions