431
average c++ dev
(programming.dev)
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Structs with union members that allow the same place in memory to be accessed either word-wise, byte-wise, or even bit-wise are a god-sent for everyone who needs to access IO-spaces, and I'm happy my C-compiler lets me do it.
#pragma push
Context?
You use it to "pack" bitfields, bytes etc together in structs/classes (wo functions), otherwise the computer usually align every variable on a 32bit boundary for speed.
You don't need that pragma to pack bitfields.
With say a 3bit int, then a 2bit int and various char, int etc and so on you did have to use the pragma with gcc & visual around 2012 at least
OK, I use the Keil ARM compiler, and never needed to push anything.
Then I'd make a unit test, there is no requirement to do so by the compiler (not even the order).