I was messing around a lot with this so
just in addition:
I am using a c unit, which i don't want to rename to *.m files. And I need a log called from there.
No wrappers could help me to avoid linker errors.
So I used the following pattern:
I made hpp and cpp files
Added an extern variable - pointer to a function to header:
extern void (*transLogFun) (const char *,...);
and its definition to cpp file
void (*transLogFun) (const char *,...) = NULL;
Then i created an h and mm file:
h:
#import <UIKit/UIKit.h>
#import "fff.hpp"
void ioslogfun(const char *s, ...);
In mm file i wrote a function and a class with its object like this:
#import "zzz.h"
#import <Foundation/Foundation.h>
void ioslogfun(const char *s, ...){
va_list vl;
va_start(vl,s);
char *str;
vasprintf(&str,s,vl);
va_end(vl);
NSLog([NSString stringWithUTF8String:str]);
free(str);
}
class Fff{
public:
Fff(){
transLogFun = &ioslogfun;
}
};
Fff initiator;
And where-ever i called the transLogFun(...) it worked fine.