0

I have been trying to improve my understanding of C/C++ but looking at includes for functions, such as printf, which I use a lot. However I am running across a syntax which I am not familiar with, nor am I able to find. What does the ':' mean? For example:

unsigned int is_long_double:1;

It seems that it would be some type of precursor to the boolean expression.

Jonathan Leffler
  • 698,132
  • 130
  • 858
  • 1,229
mreff555
  • 957
  • 8
  • 19

1 Answers1

2

It defines the variable as a bitfield of length 1 bit.

It's only valid in a struct, and only makes sense if you have multiple bitfields together.

Don't use it as a generic boolean because it doesn't save memory - a single bitfield on its own will still take up a full word of memory.

Paul Tomblin
  • 173,492
  • 58
  • 311
  • 399