3

Possible Duplicate:
what does this mean in c int a:16; ?

What does the :1 mean here:

...
unsigned respawn:1;
unsigned just_respawn:1;
unsigned detached:1;
unsigned exiting:1;
unsigned exited:1;
} ngx_process_t;
Community
  • 1
  • 1
compile-fan
  • 16,885
  • 22
  • 59
  • 73
  • 1
    Many duplicates on SO already, e.g. [what does this mean in c int a:16; ?](http://stackoverflow.com/questions/4706584/what-does-this-mean-in-c-int-a16); [Colons after variable name on C code.](http://stackoverflow.com/questions/3983943/colons-after-variable-name-on-c-code); [What does 'unsigned temp:3' means](http://stackoverflow.com/questions/2950029/what-does-unsigned-temp3-means). – Paul R May 25 '11 at 12:49

2 Answers2

5

This looks like a bit field in a struct (the header you omitted). The :1 means "1 bit wide", so in your case, they're all booleans. The compiler is supposed to optimize their space usage by packing many of them per byte.

JB.
  • 40,344
  • 12
  • 79
  • 106
3

respawn is a bitfield which is 1 bit wide, so it can take on the value of 0 or 1.

Ferruccio
  • 98,941
  • 38
  • 226
  • 299