Besides that, any compiler worth its salt should complain. On Jun 20, 2014, at 7:50 AM, Jim Jagielski <[email protected]> wrote:
> Who does that w/ bit fields? You either check if it's > true/false or you use the expected bit operations. > > On Jun 19, 2014, at 9:29 AM, Yann Ylavic <[email protected]> wrote: > >> On Thu, Jun 19, 2014 at 2:59 PM, Jim Jagielski <[email protected]> wrote: >>> >>> On Jun 19, 2014, at 8:43 AM, [email protected] wrote: >>> >>>> Author: ylavic >>>> Date: Thu Jun 19 12:43:05 2014 >>>> New Revision: 1603863 >>>> >>>> URL: http://svn.apache.org/r1603863 >>>> Log: >>>> Use unsigned bit flags (otherwise the non-zero value to be used is -1). >>>> >>> >>> I don't understand that at all... A bit is either 1 or 0. >>> >> >> Well, it depends on what you are doing with that bit... >> >> #include <stdio.h> >> int main(int argc, const char *argv[]) >> { >> struct { >> int s:1; >> } bitfield; >> >> bitfield.s = 1; >> if (bitfield.s > 0) { >> printf("positive\n"); >> } >> else { >> printf("negative or nul\n"); >> } >> if (bitfield.s == 1) { >> printf("one\n"); >> } >> else { >> printf("not one\n"); >> } >> >> return 0; >> } >> >> $ ./bitfield >> negative or nul >> not one >> >
