Question

I tried to compile my program, with Code::Blocks (gcc compiler). And I get an error: Here is the source file it complaining about:

#ifndef BOT_H
#define BOT_H

#include "player.h"
#include "timer.h"

class BOTS; // forward decalaration of BOTS

class BOT : public PLAYER
{
public:
    enum BotStatus{BotMoving,BotPursue,BotChasePowerup};
    enum BotMovDir{Up,Down,Left,Right,Forward,Backward};
    enum BotSkill{Easy,Normal,Hard,Expert,Insane};
protected:
    BotStatus Status;  // this is the line it complaining about
    BotMovDir CurrentMov;
    TIMER CTimer;
    bool Stucked;
    BotSkill Skill;
    VECTOR3D AimTarget;
//  VECTOR3D ShotTarget;
    PLAYER *PursueObj;
    bool SameLevel;
    BOTS *Owner;
    bool PlayerHitMe;
    void OnDamage(double dmg,const wchar_t *Shooter,bool s);
    void OnReset();
public:
    BOT(BOTS *o,const wchar_t *botname) : PLAYER(botname), PlayerHitMe(false), Status(BotMoving), Skill(Easy), Owner(o)
    {
        PlayerInit();
    }
    void SetSkill(BotSkill bs) {Skill=bs;}
    void BotControl();
    void SetSameLevel(bool s) {SameLevel=s;}
    virtual ~BOT() {}
};

#endif

It complains about the 16th line "multiple types in one declaration" and it is driving me crazy. I googled a lot, but the common solution is "find the missing semicolon". And the problem is that there is no missing semicolon at all. It always point to the 16th line (at least after the protected) even if there is a comment or even it is beyond the eof (when I remove all fields so the file become small).

(This problem might be trivial and I may be tired now, so I must have a sleep. And I hope someone will have given me some advice by morning tomorrow. )

Was it helpful?

Solution

Do you have a class or some other UDT named Status? What if you change the name of the member to Status_ ?

OTHER TIPS

Is "Status" a macro or otherwise declared/defined in one of the headers (or whatever they include)?

I'm a fool...

Code::Blocks sometimes doesn't save the source file before start compiling the file. MSVC++ always save it before compile. That was the real problem.

it seems there was a Status macro somewhere in the code. But it wasn't my own type. Probably a macro from a wxwidgets header...

The file you have shown us is a header file. The problem you're having is on the 16th line of some source file which is #includeing that header. Can you copy+paste the exact error message you're receiving, as well as the relevant portion of the file referenced in the error message?

There is a semi-colon missing in the last previous class declaration, not the one it's complaining about. The error is probably in "timer.h", but maybe in "player.h"

Error may be because of 2nd class forward declaration is not needed before first class definition.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top