user3153014
user3153014

Reputation: 318

Errors at declaration of enum

class API {
public:

        //States that the API can be in.
        enum API_STATE {
    /* Line 35*/ INITIAL = 0, OPENED = 1, READY = 2, STOPPED = 3, OPENFORXFER = 4
        };

I am getting errors at line 35. As follow. On include of the header file which have above code.

error: expected identifier before numeric constant
h:35: error: expected â}â before numeric constant
h:35: error: expected unqualified-id before numeric constant

Upvotes: 1

Views: 5913

Answers (1)

ecatmur
ecatmur

Reputation: 157484

You have a macro defining INITIAL (or possibly OPENED etc.) to a numeric literal:

#define INITIAL 0
enum API_STATE {
    INITIAL = 0, OPENED = 1, READY = 2, STOPPED = 3, OPENFORXFER = 4
};

Clang gives precisely the error you reported:

!!error: expected identifier before numeric constant
!!error: expected ‘}’ before numeric constant
!!error: expected unqualified-id before numeric constant

Upvotes: 3

Related Questions