Testing an enumeration gives a warning: a comparison between a pointer and an integer

I get this warning:

warning: comparison between pointer and integer

when performing the following actions:

if (menuItem.menuType == LinkExternal)

MenuType is a custom enumeration listed below:

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

enum menuItemType *menuType;

I guess I just need cast, but what is the syntax?

+3
source share
1 answer

Since your menuType type is a pointer to an enum value, you can rewrite your condition:

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

But why do you need to store this value in a pointer? You cannot just:

enum menuItemType menuType;
+11
source

Source: https://habr.com/ru/post/1729561/


All Articles