Compiler errors Cocos 2d表达式错误

Compiler errors Cocos 2d表达式错误,compiler-errors,cocos2d-iphone,syntax-error,c-preprocessor,Compiler Errors,Cocos2d Iphone,Syntax Error,C Preprocessor,我试图通过运行下面的代码来检测应用程序运行在哪个iPhone上,但我得到了一个预期的表达式错误 #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) #define IS_RETINA ([[UIScreen mainScreen] scale] >= 2

我试图通过运行下面的代码来检测应用程序运行在哪个iPhone上,但我得到了一个预期的表达式错误

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)

#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))

#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)
下面是代码:

bool MainScene::init()
    {



    if ( !CCLayer::init() )
    {
        return false;
    }

    MyGameBridge::showBanner();


    g_nScore = 0;



    r =  72;
    g =  180;
    b =  187;
    CCLayerColor *background = CCLayerColor::create(ccc4(r, g, b, 255), G_SWIDTH, G_SHEIGHT);
    this->addChild(background, 0);




    newSprite("ground", G_SWIDTH/2, G_SHEIGHT / 2, this, 2, RATIO_XY);

    newSprite("Player", G_SWIDTH/2, getY(855), this, 0, RATIO_X);

    //    newSprite(CCString::createWithFormat("bg_main%d_en", graphics_mode)->getCString(), G_SWIDTH/2, G_SHEIGHT/2, this, 0, RATIO_XY);

    CCMenuItemToggle* btnSound=newToggleButton("sound", G_SWIDTH/2 - getX(150), getY(650), this, menu_selector(MainScene::onClickSound), true, RATIO_X);
    btnSound->setSelectedIndex(g_bSound?0:1);
    CCMenuItemImage *scoreItem=newButton(CCString::createWithFormat("btn_score")->getCString(), G_SWIDTH/2 + getX(150), getY(650), this, menu_selector(MainScene::onClickScore), true, RATIO_X);
    scoreItem->setScale(G_SCALEX*0.95);
     //    scoreItem->setScaleY(G_SCALEY*0.9);


    // sets the postion, and image of the play button

    CCMenu* menu;
    menu = CCMenu::create(
                          newButton(CCString::createWithFormat("Play")->getCString(), G_SWIDTH/2, getY(500), this, menu_selector(MainScene::onClickPlay), true, RATIO_X),

                          scoreItem,

                          btnSound,

                          NULL);

    menu->setPosition(0, 0);
    this->addChild(menu);


    if(IS_IPHONE_6P) // Here is where the expression error occurs
    {
        NSLog(@"IS_IPHONE_6P");
    }



    //adds the title

    newLabel(CCString::createWithFormat("Pop Up!")->getCString(), CCString::createWithFormat("DINAlternate-Bold")->getCString(), 200, G_SWIDTH / 2, getY(150), this, 2, RATIO_Y);

    // adds the highscore title

    newLabel(CCString::createWithFormat("Best: %d", g_nBestScore)->getCString(), CCString::createWithFormat("Arial")->getCString(), 85, G_SWIDTH / 2, getY(270), this, 2, RATIO_Y);




    return true;



}

我需要修复/编辑什么

准确的错误信息,请。。。在哪一行?我得到错误:解析问题,预期表达式。在这行代码中。。。如果(IS#IPHONE_6P){NSLog(@“IS#IPHONE_6P”)}您的代码(#defines+if)在我的例子中编译得非常好。如果,请尝试注释
,并检查错误是否仍然存在?你会尝试使用
IS\u IPAD
而不是
IS\u IPHONE\u 6P
并再次检查吗?你的两种解决方案我都试过了,都不管用。我实际上有三个错误:1。语义问题使用未声明的标识符“UI\u用户界面\u惯用语”2。未声明标识符“UIUserinterfaceidiomiPhone”3的语义问题使用。分析问题,应为标识符
bool MainScene::init()
    {



    if ( !CCLayer::init() )
    {
        return false;
    }

    MyGameBridge::showBanner();


    g_nScore = 0;



    r =  72;
    g =  180;
    b =  187;
    CCLayerColor *background = CCLayerColor::create(ccc4(r, g, b, 255), G_SWIDTH, G_SHEIGHT);
    this->addChild(background, 0);




    newSprite("ground", G_SWIDTH/2, G_SHEIGHT / 2, this, 2, RATIO_XY);

    newSprite("Player", G_SWIDTH/2, getY(855), this, 0, RATIO_X);

    //    newSprite(CCString::createWithFormat("bg_main%d_en", graphics_mode)->getCString(), G_SWIDTH/2, G_SHEIGHT/2, this, 0, RATIO_XY);

    CCMenuItemToggle* btnSound=newToggleButton("sound", G_SWIDTH/2 - getX(150), getY(650), this, menu_selector(MainScene::onClickSound), true, RATIO_X);
    btnSound->setSelectedIndex(g_bSound?0:1);
    CCMenuItemImage *scoreItem=newButton(CCString::createWithFormat("btn_score")->getCString(), G_SWIDTH/2 + getX(150), getY(650), this, menu_selector(MainScene::onClickScore), true, RATIO_X);
    scoreItem->setScale(G_SCALEX*0.95);
     //    scoreItem->setScaleY(G_SCALEY*0.9);


    // sets the postion, and image of the play button

    CCMenu* menu;
    menu = CCMenu::create(
                          newButton(CCString::createWithFormat("Play")->getCString(), G_SWIDTH/2, getY(500), this, menu_selector(MainScene::onClickPlay), true, RATIO_X),

                          scoreItem,

                          btnSound,

                          NULL);

    menu->setPosition(0, 0);
    this->addChild(menu);


    if(IS_IPHONE_6P) // Here is where the expression error occurs
    {
        NSLog(@"IS_IPHONE_6P");
    }



    //adds the title

    newLabel(CCString::createWithFormat("Pop Up!")->getCString(), CCString::createWithFormat("DINAlternate-Bold")->getCString(), 200, G_SWIDTH / 2, getY(150), this, 2, RATIO_Y);

    // adds the highscore title

    newLabel(CCString::createWithFormat("Best: %d", g_nBestScore)->getCString(), CCString::createWithFormat("Arial")->getCString(), 85, G_SWIDTH / 2, getY(270), this, 2, RATIO_Y);




    return true;



}