if ((flag & FLAG_VALUE) == TRUE) ...
That would still check if flag is 1, right?That is correct.
Indeed, great catch (this is why I use things like QFlags now, as it has a simple "testFlag" method)
flag&FLAG_VALUE will be FLAG_VALUE or 0, so unless FLAG_VALUE==TRUE the answer could be wrong.
Suggest (flag&FLAG_VALUE), or, if you need the expression to be of type bool, ((flag&FLAG_VALUE)!=0) or (!!(flag&FLAG_VALUE)).
Very true, I just checked to see if I can edit but I can't, so mea culpa.
Boolean true / TRUE wasn't defined in any standard way before C99. Back in the "olden days", most programmers #defined it as 1, but not always. I ran into one of those "not always" cases in some inherited code.
What you want varies but is probably something like:
that kind of thing.