I created a function in a Cocoa Framework that I want to export. This function is implement in ObjectiveC++, and the name mangling of C++ is driving me nuts.
I already declared the function within an extern "C" block, to no avail.
This is my header file in the framework:
#import <Cocoa/Cocoa.h>
extern "C"{
void display(NSString *text);
}
@interface Display : NSObject
@end
and this is the .mm file:
#import "Display.h"
#include <string>
#include <iostream>
using namespace std;
void display(NSString *text){
cout << [text cStringUsingEncoding:NSUTF8StringEncoding] << endl;
}
@implementation Display
@end
It compiles fine, without any errors.
On the client side, I added the framework, imported the exposed header and tried to call the function:
display(@"Hola");
Here I get a warning complaining that "implicit declaration of function display is invalid in C99".
To add insult to injury, in the exposed header file I get an error (that doesn't show up in the framework project), in the extern "C" line:
"expected identifier or ("
What else is necessary to get this going?