: operator (colon)

closed account (1yR4jE8b)
Alright, I've been doing some Gtk+ development as of late, and I've been going over the documentation of certain enumerations and structs in the library. I came across the follow struct, and I'm not very clear on what some of the variables definitions mean:

1
2
3
4
5
6
7
8
9
typedef struct
{
  GtkWidget *widget;
  guint16 padding;
  guint expand : 1;
  guint fill : 1;
  guint pack : 1;
  guint is_secondary : 1;
} GtkBoxChild;


I'm aware of the : operator used in the ternary ?: operation, but I have never seen it used in a variable definition and I'm not exactly sure what the significance of it is.

Thanks in advance.
It means bitfield.

It means that expand occupies 1 bit, for example.

closed account (1yR4jE8b)
Alright, so if the expand field only occupies 1 bit, that means I can only store a value of 0 or 1 in that field, and not an entire guint?
Correct.
Topic archived. No new replies allowed.