Skip to content

Instantly share code, notes, and snippets.

@lighth7015
Created May 2, 2020 14:22
Show Gist options
  • Save lighth7015/8cae2c42a94f59b77275ad25ecdae8ee to your computer and use it in GitHub Desktop.
Save lighth7015/8cae2c42a94f59b77275ad25ecdae8ee to your computer and use it in GitHub Desktop.
Calculating maximum number based on value of enum
#include <stdio.h>
enum { MAX_NUM_OBJECTS = 29 };
typedef struct {
union {
uint32_t mask;
struct {
bool available : 1;
bool client : 1;
bool inproc : 1;
uint32_t index : MAX_NUM_OBJECTS;
};
};
} ObjectInfo;
int main() {
printf("The maximum number of entries is a calculation involving MAX_NUM_OBJECTS (%x).\n", 0);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment