Tag Archives: alignment

Alignment and Packing

Here’s a topic relevant to both the new books I’m writing. Consider the following small program: char foo[] = {1, 2, 3, 4, 5, 6, 7, 8}; void setup() { Serial.begin(9600); while (!Serial); Serial.println(*(uint32_t *)&foo[0], HEX); Serial.println(*(uint32_t *)&foo[1], HEX); Serial.println(*(uint32_t *)&foo[2], HEX); Serial.println(*(uint32_t *)&foo[3], HEX); } void loop() { } If you run this on …