C++ 错误:在';之前应为非限定id;不是';令牌gc++;建设者

C++ 错误:在';之前应为非限定id;不是';令牌gc++;建设者,c++,cygwin,C++,Cygwin,我在程序中有一个类通知,我在这个项目的其他类中使用它。当我在VisualStudio2010中运行时,一切正常。但当使用Cygwin build occcur时,会出现以下错误“错误:在'not'标记之前应为非限定id” 这是我的班级档案 #ifndef __TOAST_H__ #define __TOAST_H__ #include "cocos2d.h" #include "cocos-ext.h" USING_NS_CC_EXT; USING_NS_CC; #define LOADIN

我在程序中有一个类通知,我在这个项目的其他类中使用它。当我在VisualStudio2010中运行时,一切正常。但当使用Cygwin build occcur时,会出现以下错误“错误:在'not'标记之前应为非限定id” 这是我的班级档案

#ifndef __TOAST_H__
#define __TOAST_H__

#include "cocos2d.h"
#include "cocos-ext.h"
USING_NS_CC_EXT;
USING_NS_CC;

#define LOADING 1

class notificationTOAST: public CCLayer{
public:
    notificationTOAST(char* bg, char* txt, float y, float duringTime, CCObject* target);
    notificationTOAST(char* bg, char* txt, float y, float duringTime, CCObject* target,char* imgLoading);
    notificationTOAST(char* bg, char* txt, float duringTime, CCObject* target);
    notificationTOAST(char* bg, char* txt, float x, float y, float duringTime, CCObject* target);
    notificationTOAST(char* bg, char* txt,float x, float y, float duringTime, CCObject* target,char* imgLoading);
    void end();
    virtual void loop(float id);
private:
    float duringTime;
    CCObject* target;
};

#endif
文件.cpp

#include "Toast.h"
#include "Constant.h"

notificationTOAST::notificationTOAST(char* bg, char* txt, float y, float duringTime, CCObject* target){
this->target = target;
CCLabelTTF *text = CCLabelTTF::create(txt, font_arial, 20);

text->setPosition(ccp(SCREEN_W/2, y));
addChild(text,1);
CCScale9Sprite* background = CCScale9Sprite::create(bg);
background->setContentSize(CCSizeMake(text->getContentSize().width + 40, text->getContentSize().height +20));
background->setPosition(ccp(SCREEN_W/2, y));
addChild(background);
this->duringTime = duringTime;
if(duringTime > 0){
    schedule(schedule_selector(notificationTOAST::loop));
}
this->runAction(CCFadeIn::create(0.3f));
this->autorelease();
}
notificationTOAST::notificationTOAST(char* bg, char* txt, float x, float y, float duringTime, CCObject* target){
this->target = target;
CCLabelTTF *text = CCLabelTTF::create(txt, font_arial, 20);

text->setPosition(ccp(x, y));
addChild(text,1);
CCScale9Sprite* background = CCScale9Sprite::create(bg);
background->setContentSize(CCSizeMake(text->getContentSize().width + 40, text->getContentSize().height +20));
background->setPosition(ccp(x, y));
addChild(background);
this->duringTime = duringTime;
if(duringTime > 0){
    schedule(schedule_selector(notificationTOAST::loop));
}
this->runAction(CCFadeIn::create(0.3f));
this->autorelease();
}
notificationTOAST::notificationTOAST(char* bg, char* txt, float y, float duringTime, CCObject* target,char* imgLoading){
this->target = target;
CCLabelTTF *text = CCLabelTTF::create(txt, font_arial, 20);
CCSprite* loading = CCSprite::create("progress.png");
int w = text->getContentSize().width + loading->getContentSize().width + 5;
int h = loading->getContentSize().height;

loading->setPosition(ccp(SCREEN_W/2 - w/2 + loading->getContentSize().width/2,y));
CCActionInterval* rotage = CCRotateBy::create(2.0f, 360);
loading->runAction(CCRepeatForever::create(rotage));
addChild(loading,1,LOADING);
text->setPosition(ccp(SCREEN_W/2 - w/2 + loading->getContentSize().width + text->getContentSize().width/2 + 5, y));
addChild(text,1);

CCScale9Sprite* background = CCScale9Sprite::create("bgloading.png");
background->setContentSize(CCSizeMake(w + 10, h));
background->setPosition(ccp(SCREEN_W/2, y));
addChild(background);
this->duringTime = duringTime;
if(duringTime > 0){
    schedule(schedule_selector(notificationTOAST::loop));
}
this->runAction(CCFadeIn::create(0.1f));
this->autorelease();

}
notificationTOAST::notificationTOAST(char* bg, char* txt,float x, float y, float duringTime, CCObject* target,char* imgLoading){
this->target = target;
CCLabelTTF *text = CCLabelTTF::create(txt, font_arial, 20);
CCSprite* loading = CCSprite::create("progress.png");
int w = text->getContentSize().width + loading->getContentSize().width + 5;
int h = loading->getContentSize().height;

loading->setPosition(ccp(SCREEN_W*2/3 - w/2 + loading->getContentSize().width/2,y));
CCActionInterval* rotage = CCRotateBy::create(2.0f, 360);
loading->runAction(CCRepeatForever::create(rotage));
addChild(loading,1,LOADING);
text->setPosition(ccp(SCREEN_W*2/3 - w/2 + loading->getContentSize().width + text->getContentSize().width/2 + 5, y));
addChild(text,1);

CCScale9Sprite* background = CCScale9Sprite::create("bgloading.png");
background->setContentSize(CCSizeMake(w + 10, h));
background->setPosition(ccp(SCREEN_W*2/3, y));
addChild(background);
this->duringTime = duringTime;
if(duringTime > 0){
    schedule(schedule_selector(notificationTOAST::loop));
}
this->runAction(CCFadeIn::create(0.1f));
this->autorelease();

}

notificationTOAST::notificationTOAST(char* bg, char* txt, float duringTime, CCObject* target){
this->target = target;
CCLabelTTF *text = CCLabelTTF::create(txt, font_arial, 20);

CCScale9Sprite* background = CCScale9Sprite::create(bg);
background->setPosition(ccp(SCREEN_W/2,SCREEN_H- background->getContentSize().height/2));
addChild(background);

int w = background->getContentSize().width;
int h = background->getContentSize().height;

text->setPosition(ccp(SCREEN_W + text->getContentSize().width/2, SCREEN_H-h/2));
addChild(text,1);
CCFiniteTimeAction* seq = CCSequence::create(CCMoveBy::create(20,CCPointMake(-(SCREEN_W + text->getContentSize().width + 50),0)), 
                                     CCMoveTo::create(0,CCPointMake(SCREEN_W + text->getContentSize().width/2, SCREEN_H-h/2)),
                                     NULL);
text->runAction(CCRepeatForever::create((CCActionInterval*)seq));




this->duringTime = duringTime;
if(duringTime > 0){
    schedule(schedule_selector(notificationTOAST::loop));
}

this->autorelease();

}

void notificationTOAST::loop(float id){

if(duringTime == -1) return;
duringTime -= id;
if(duringTime <= 0){
    duringTime = 10;

    //this->stopAllActions();
    CCLayer* aLayer = (CCLayer*) target;
    aLayer->removeChild(this);
}

}

void notificationTOAST::end(){
CCLayer* aLayer = (CCLayer*) target;
aLayer->removeChild(this);
}

<代码> 是C++中的关键字(<代码>别名>代码>别名)。将变量重命名为其他变量。

< P> <代码>不是/C>是C++关键字,代码<别名>!代码>操作员


<微软VisualC++是众所周知的,当微软不喜欢它时,不遵循规范。当他们现有的代码库不符合时,他们不喜欢这个规范,他们有一个bug,不想修复它或其他任何原因。不要依赖MSVC++检查任何本应可移植的代码。

欢迎使用Stackoverflow。你能用“编辑”按钮修改格式吗?您可以使用。
\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu!我编辑了你的文章以使其更具可读性,但你的代码仍然很不清楚。你应该看看这些变化。:)+1.想必是为了避免破坏旧代码,VisualStudio倾向于忽略标准的这一部分,除非您在编译器命令行上显式启用它,这当然只是鼓励您在VS now中编写破坏的/不可移植的新代码。
notificationTOAST *not = new notificationTOAST("","Loading...",SCREEN_W/2  ,SCREEN_H/2+50,3,GameController::getInstance(),"");
    not->setTag(100);
    GameController::getInstance()->addChild(not);`