I would like to be able to check two flags in a single condition but I can't find the right way to do it.
Here is an example of one of the things I tried:
#include <stdio.h>
#define FLAG_1 0x01
#define FLAG_2 0x02
void check_flags(int flags)
{
if (flags & FLAG_1)
printf("Flag 1\n");
else if (flags & FLAG_2)
printf("Flag 2\n");
else if (flags & FLAG_1 | FLAG_2)
printf("Flag 1 and 2\n");
}
int main(void)
{
check_flags(FLAG_1 | FLAG_2);
return 0;
}