Skip to content

Instantly share code, notes, and snippets.

View LabunskyA's full-sized avatar
💭
Doing useless research

Labunsky Artem LabunskyA

💭
Doing useless research
View GitHub Profile
@LabunskyA
LabunskyA / raw_ctype.h
Last active June 30, 2022 08:58
Save space on C structures padding (compiler-independent)
/*
* 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
* }
*