0

私はクロスプラットフォームの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];

}

上記のコードは完全に機能します。関数内にobjective-cを持つc++クラスのc++関数。しかし、私がこれを行うとき:

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

}

いくつかのエラーが発生します。主に:variable has incomplete type 'void。私も取得しexpected primary expression before '<'tokenます。そしてまた興味深い:expected ';' after top level declarator。これは、クラスのヘッダーファイルです。

#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

xcodeがc++とObjectiveCのミキシングに夢中になっている理由は何ですか?

4

1 に答える 1

3

<#const char *text#>あるべきだと思いますconst char *text

<#とは#>、Xcode のオートコンプリート システムによって配置されたものであり、削除する必要があります。

于 2012-10-06T06:37:08.810 に答える