开发者

Testing enum gives warning: comparison between pointer and integer

开发者 https://www.devze.com 2022-12-17 15:09 出处:网络
I am getting开发者_C百科 this warning: warning: comparison between pointer and integer when doing the following:

I am getting开发者_C百科 this warning:

warning: comparison between pointer and integer

when doing the following:

if (menuItem.menuType == LinkExternal)

MenuType is a custom enum defined as below:

enum menuItemType
{
    LinkInternal = 0,
    LinkExternal = 1,
    Image = 2,
    Movie = 3,
    MapQuery = 4
};

enum menuItemType *menuType;

I assume I just need a cast but what is the syntax?


As your menuType is a pointer to enum value you can rewrite your condition:

if (*(menuItem.menuType) == LinkExternal)

But why do you need to store this value by pointer? Can't you have just:

enum menuItemType menuType;
0

精彩评论

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

关注公众号