Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing enum gives warning: comparison between pointer and integer

I am getting 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?

like image 365
Anthony Main Avatar asked Dec 17 '22 03:12

Anthony Main


1 Answers

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;
like image 165
Vladimir Avatar answered Apr 21 '23 16:04

Vladimir