开发者

C++ enum value initialization

开发者 https://www.devze.com 2022-12-11 21:19 出处:网络
I have an enum declared in my code as: enum REMOTE_CONN { REMOTE_CONN_DEFAULT = 0, REMOTE_CONN_EX_MAN = 10000,

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_C开发者_开发问答ONN_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?


OK, I'll guess.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号