Xcode变量具有不完整类型void

时间:2023-01-18 19:57:43

I am working on a cross platform c++ app. On the mac version I need to use a little bit of cocoa in obj-c. So I have made a class called OSXSpecifics and it has the .mm file extension and a c++ header like the rest of the app.

我正在开发一个跨平台的c ++应用程序。在mac版本上我需要在obj-c中使用一点点可可。所以我创建了一个名为OSXSpecifics的类,它具有.mm文件扩展名和c ++标题,就像应用程序的其余部分一样。

std::string OSXSpecifics::GetOSXFilePath(const char *name, const char *type) {
return [[[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String: name]
                                        ofType:[NSString stringWithUTF8String: type]] UTF8String];

}

The above code works absolutely perfect. A c++ function in a c++ class with objective-c inside the function. But when I do this:

上面的代码非常完美。 c ++类中的c ++函数,在函数内部使用objective-c。但是当我这样做时:

void OSXSpecifics::printToConsole(<#const char *text#>) {
NSString *Text = [NSString stringWithUTF8String: text];

}

I get a couple of errors. Mainly: variable has incomplete type 'void. I also get expected primary expression before '<'token. And also of interest: expected ';' after top level declarator. This is the header file for the class:

我收到了一些错误。主要是:变量具有不完整类型'void。我也在“<”标记之前得到了预期的主表达式。还有兴趣:期待';'在*声明者之后。这是该类的头文件:

#ifndef OSXSPECIFICS_h
#define OSXSPECIFICS_h

#include <string.h>

class OSXSpecifics
{
public:
    static std::string GetOSXFilePath(const char* name, const char* type);
    static void printToConsole(const char* text);
};

#endif // OSXSPECIFICS_h

Any idea's why xcode is freaking out about c++ and objective c mixing?

任何想法都是为什么xcode对c ++和客观c混合感到害怕?

1 个解决方案

#1


3  

I think <#const char *text#> should be const char *text.

我认为<#const char * text#>应该是const char * text。

The <# and #> were put there by Xcode's autocomplete system and should be removed.

<#和#>由Xcode的自动完成系统放在那里,应该删除。

#1


3  

I think <#const char *text#> should be const char *text.

我认为<#const char * text#>应该是const char * text。

The <# and #> were put there by Xcode's autocomplete system and should be removed.

<#和#>由Xcode的自动完成系统放在那里,应该删除。

相关文章