c bit access struct
typedef union a429_tag { // define a union of structs and/or raw data types
// struct to access each bit individually
struct {
unsigned int
bit0 : 1, bit1 : 1, bit2 : 1, bit3 : 1,
bit4 : 1, bit5 : 1, bit6 : 1, bit7 : 1,
bit8 : 1, bit9 : 1, bit10 : 1, bit11 : 1,
bit12 : 1, bit13 : 1, bit14 : 1, bit15 : 1;
};
// struct to access range of bits by name
struct {
unsigned int
label : 8,
sdi : 2,
data : 3,
ssm : 2,
parity : 1;
};
// int type to access to the entire word as an integer
unsigned int word : 16;
} a429_type;
/* Example usage */
int main() {
a429_type myUnion;
myUnion.parity = 1;
if (myUnion.bit15 == 1) {
printf("parity and bit15 refer to the same bit");
}
return 0;
}
Also in C:
- linux sleep with exec /bin/sleep
- c float to int
- ModuleNotFoundError: No module named 'cv2'
- array addition and multiplication in c
- fgets in c
- powershell some fonts like #include are dissapearing
- excel cell blank or zero
- how to draw a graph or histogram in c language
- c program to find number of days in a month using switch case
- jframe mittig positionieren
- read a binary file c
- strcpy c implementation
- find string in all files powershell
- read a document in c getting name from console
- c vs python
- pygame detect click
- how to ascii art in c
- how to free memory in c
- bcopy
- table fixed header
- pthread_create
- Search Code Snippets
- unable to locate package dos2unix
- c strcmp