Created
November 22, 2015 04:40
-
-
Save karlding/54846c26e627e00c7fd1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdbool.h> | |
int main() { | |
union { | |
struct { | |
bool bit0 : 1; | |
bool bit1 : 1; | |
bool bit2 : 1; | |
bool bit3 : 1; | |
bool bit4 : 1; | |
bool bit5 : 1; | |
bool bit6 : 1; | |
bool bit7 : 1; | |
bool bit8 : 1; | |
bool bit9 : 1; | |
bool bit10 : 1; | |
bool bit11 : 1; | |
bool bit12 : 1; | |
bool bit13 : 1; | |
bool bit14 : 1; | |
bool bit15 : 1; | |
bool bit16 : 1; | |
bool bit17 : 1; | |
bool bit18 : 1; | |
bool bit19 : 1; | |
bool bit20 : 1; | |
bool bit21 : 1; | |
bool bit22 : 1; | |
bool bit23 : 1; | |
bool bit24 : 1; | |
bool bit25 : 1; | |
bool bit26 : 1; | |
bool bit27 : 1; | |
bool bit28 : 1; | |
bool bit29 : 1; | |
bool bit30 : 1; | |
bool bit31 : 1; | |
}; | |
uint8_t byte[4]; | |
uint16_t word[2]; | |
uint32_t data; | |
} msg; | |
uint32_t test = 0xF800030A; | |
msg.data = test; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment