错误预期标识符或(

abd*_*.me 1 c plugins objective-c unity-game-engine

嗨,大家好我遇到了问题预期的标识符或(以下是.h文件中的代码

 #import <Foundation/Foundation.h>
    #import "HelloWordPlugin.h"

    extern "C"   //Error Expected identifier or (
    {
        void _displayUIAlertViewWithTitleAndMessage(const char* title, const char* message);
    }

    NSString* CreateNSString(const char* string);
    char* MakeStringCopy(const char* string);
Run Code Online (Sandbox Code Playgroud)

我在.mm文件中添加了他们的定义,我无法找到实际问题,请指教

Dav*_*nan 7

据我所知,它extern "C"在Obj-C中没有意义,就像它在普通C中没有意义一样.你应该删除extern "C"因为你已经有了C链接.

如果您希望您的代码以C++编译,那么您将需要extern "C",但包装在一起#ifdef __cplusplus以便Obj-C编译器不会看到它.