我正在尝试写入此头文件:

//@class AQPlayer;

//#import "AQPlayer.h"

@interface AQ_PWN_iPhoneViewController : UIViewController {

    AQPlayer* player;
}

@end

aqplayer是用c++编写的.mm文件。
我试图在这里做一个类转发声明,但它抱怨我:
error: cannot find interface declaration for 'AQPlayer'
所以我试着“导入”头文件,但它抱怨完全关闭和奇怪的东西。这里有一部分错误被投诉:
包含在文件中
/Users/akaraphan/Desktop/SpecialTopic1/AQ_PWN_iPhone/Classes/AQPlayer.h:51,
                 from /Users/akaraphan/Desktop/SpecialTopic1/AQ_PWN_iPhone/Classes/AQ_PWN_iPhoneViewController.h:12,
                 from /Users/akaraphan/Desktop/SpecialTopic1/AQ_PWN_iPhone/Classes/AQ_PWN_iPhoneAppDelegate.m:10:
/Developer/Examples/CoreAudio/PublicUtility/CAStreamBasicDescription.h:78: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CAStreamBasicDescription'
/Developer/Examples/CoreAudio/PublicUtility/CAStreamBasicDescription.h:230: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
/Developer/Examples/CoreAudio/PublicUtility/CAStreamBasicDescription.h:231: error: expected '=', ',', ';', 'asm' or '__attribute__' before '==' token
/Developer/Examples/CoreAudio/PublicUtility/CAStreamBasicDescription.h:233: error: expected '=', ',', ';', 'asm' or '__attribute__' before '!=' token
/Developer/Examples/CoreAudio/PublicUtility/CAStreamBasicDescription.h:234: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<=' token
/Developer/Examples/CoreAudio/PublicUtility/CAStreamBasicDescription.h:235: error: expected '=', ',', ';', 'asm' or '__attribute__' before '>=' token
/Developer/Examples/CoreAudio/PublicUtility/CAStreamBasicDescription.h:236: error: expected '=', ',', ';', 'asm' or '__attribute__' before '>' token
/Developer/Examples/CoreAudio/PublicUtility/CAStreamBasicDescription.h:239: error: expected ';', ',' or ')' before '&' token

我遗漏了什么吗?我不能做个远期申报吗?

最佳答案

通常的做法是:

// In your .h file...
@class AQPlayer;
@interface AQ_PWN_iPhoneViewController : UIViewController {
    AQPlayer *player;
}
@end

// In your .mm file (see below why it has to be .mm instead of .m)...
#import "AQ_PWN_iPhoneViewController.h"
#import "AQPlayer.h"
@implementation AQ_PWN_iPhoneViewController
...
@end

您所看到的重载错误可能是因为编译器试图解析AQPlayer.h为ObjuleC而不是Objto-C++。对于所有导入AQPoPE的源文件,您可能需要使用.mm,即使该特定类不使用C++。

10-08 09:23