The following code:
#include <stdint.h>
uint8_t byte = 0x12;
uint16_t word = 0x1234;
int main(int argc, char *argv[])
{
return 0;
}
Inspecting the .data
section, it shows that byte
variable 2 bytes, not 1 as uint8_t
promises:
Hex dump of section '.data':
0x00601020 00000000 00000000 00000000 00000000 ................
0x00601030 12003412 ..4.
How can we ensure that byte
is 1 byte, even it makes the memory misaligned? I tried adding #pragam pack(1)
but it's still the same.