Question : c declaration type

hi

i came across this decalaration in a .h file

unsigned                sendquitmsg:1;

i havent seen this style of declaration in C programing before...any knows ahat this does exactly?

what are other ways of doing teh same thing? is the way fo decalaryion more efficient than others?

Answer : c declaration type

>> ngx_flag_t               sendquitmsg = (s->sendquitmsg != 0);

s is a pointer to an instance of the struct that contains sendquitmsg bitfield.

s->sendquitmsg gets the value of the sendquitmsg bitfield for the s instance.

(s->sendquitmsg != 0) is true if the bitfield value is not 0 (ie. it's 1), and false if the bitfield value is 0. This result (true or false) is then assigned to the variable sendquitmsg.
Random Solutions  
 
programming4us programming4us