我经历了Objective-C++的一些奇怪的行为。我有一个Objective-C++类,它在方法体中调用一个经典的C函数。但是链接器找不到C函数。
我在这里描述了问题:Xcode print symbol not found for my C function which used in Objective-C method body
我通过将Objective-C++类更改为Objective-C类解决了这个问题,但问题仍然存在。是否禁止在Objective-C++类中调用C函数?
发布于 2010-02-07 00:08:17
您需要确保声明了C函数
extern "C"在适当的.h文件中。
执行此操作的常见方法是:
//
// foo.h
//
#ifndef __FOO_H__
#define __FOO_H__
#ifdef __cplusplus
extern "C" {
#endif
// ... your interface here - normal C function declarations etc ...
#ifdef __cplusplus
}
#endif
#endifhttps://stackoverflow.com/questions/2213692
复制相似问题