You did not indicate in your question exactly what you do not understand, but in your example there are at least four things that you cannot find in the βclassicalβ literature of C or from a general search in structures. These are:
- Bit field members
- Assigned Initializers
- Explicit Width Data Types
- Boolean constants
Battlefields have always been in ISO / ANSI C, but are usually not used. Although they can lead to efficient data structures with memory, on most architectures they generate more code for access and access, they may not be atomic, which is a problem when sharing data between interrupted or streaming contexts. In addition, the packing of bitfields is determined by the implementation, therefore, it can lead to intolerable code in applications where the exact bit position is important (for example, when superimposing a hardware register).
Assigned initializers have been introduced in ISO C99. There is not much specific literature on C99, most C literature prescribes it in advance or adheres to a subset of C90 for compatibility. You have to look for the C99 specifically if you want to find information - these are the things.
Explicit width data types ( uint8_t in this case) have also been introduced with C99, but are simply implemented as typedef built-in aliases in the standard stdint.h header, so they can be implemented in C90 compilers too.
Similarly, C99 introduced the boolean literals true and false , as well as the bool data type. C99 bool has a typedef alias for _Bool defined in stdbool.h , as well as definitions for true and false . You can define bool and true and false in C90 if you choose this, but it lacks the _Bool built-in data _Bool , so you should use a different type of integral.
source share