Assuming that I have this:
enum { A = 0x2E, B = 0x23, C = 0x40 }
it’s possible check if x is defined into enum?
I’m doing it manually: int isdef = (x == A || x == B || x == C); But I want to something more dynamic. GCC-extensions are welcome too.
This is kind of a modified version of your question, but depending on what you’re doing, something like this might work:
which outputs
EDIT: TJD beat me to it, and his suggestion of using a sorted array and doing binary search would decrease your search time from n to log(n).