Gayan
Gayan

Reputation: 1737

C++ enum value initialization

I have an enum declared in my code as:

enum REMOTE_CONN
{
    REMOTE_CONN_DEFAULT = 0,
    REMOTE_CONN_EX_MAN = 10000,
    REMOTE_CONN_SD_ANNOUNCE,
    REMOTE_CONN_SD_IO,
    REMOTE_CONN_AL,
    REMOTE_CONN_DS
};

I expect the value of REMOTE_CONN_SD_IO to be 10002, but when debugging the value of ((int)REMOTE_CONN_SD_IO) was given as 3.

Another component uses the same enum and it gives the expected value of 10002 to REMOTE_CONN_SD_IO.

What could be the reason for this?

Upvotes: 0

Views: 2590

Answers (2)

Andrew Shepherd
Andrew Shepherd

Reputation: 45232

OK, I'll guess.

The first component was built before you changed the code in the header. Try rebuilding the offending component.

Upvotes: 1

Jeff Paquette
Jeff Paquette

Reputation: 7127

One possible answer is that your executable wasn't rebuilt properly after you set REMOTE_CONN_EN_MA = 10000 so what your debugging doesn't match what you're looking at.

Upvotes: 0

Related Questions