Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Doing useless research

Labunsky Artem LabunskyA

💭
Doing useless research
View GitHub Profile
@LabunskyA
LabunskyA / raw_ctype.h
Created Jun 28, 2019
Save space on C structures padding not relying on the compiler
View raw_ctype.h
/*
* Use this macro to define variables to save space in your structures
* Imagine you have the following structure:
* struct A {
* void* my_ptr; // 8 bytes
*
* uint8_t my_flag :1; // merged with the next
* uint16_t my_uint :15; // 2 bytes total
* }
*