1
typedef struct{
        unsigned  flanke:1;         
        unsigned  lastState:1;  
        } flanke_t;

I do not understand the ":1". Please help me, thx.

CB Bailey
  • 755,051
  • 104
  • 632
  • 656
nomnom
  • 1,560
  • 5
  • 17
  • 31

2 Answers2

3

These are bit fields: https://en.wikipedia.org/wiki/Bit_field. Here you just reserve 1 bit for 'flanke' and one for the 'lastState'. The type has to be unsigned int.

Stasik
  • 2,568
  • 1
  • 25
  • 44
2

What you see here is bit field declaration usage. it is used to indicate the number of bits a given structure member will occupy in the structure so its main usage is to pack a structure so that it occupies less memory.

Ivaylo Strandjev
  • 69,226
  • 18
  • 123
  • 176