Top "Memory-alignment" questions

Memory alignment means that objects and variables reside at particular offsets in the system's memory.

What are the differences between #pragma pack(push, n)/#pragma pack(pop) and __attribute__((__packed__, aligned(n) )) on GCC?

On GCC specifically (that is, compiling both with GCC), what are the differences between the way the following two work? …

c++ c gcc memory-alignment
What does the ".align" x86 Assembler directive do exactly?

I will list exactly what I do not understand, and show you the parts I can not understand as well. …

assembly x86 memory-alignment gnu-assembler
How is the size of a C++ class determined?

Summary: How does the compiler statically determine the size of a C++ class during compilation? Details: I'm trying to understand …

c++ memory-alignment
What exactly is an 'aligned pointer'?

Would somebody please tell me what an aligned pointer actually means?

c++ c memory-alignment
How to trap unaligned memory access?

I am working on a pet open-source project that implements some stream cipher algorithms and I am having trouble with …

c linux arm memory-alignment
Atomicity in C++ : Myth or Reality

I have been reading an article about Lockless Programming in MSDN. It says : On all modern processors, you can assume …

c++ atomic memory-alignment
Do class/struct members always get created in memory in the order they were declared?

This is a question that was sparked by Rob Walker's answer here. Suppose I declare a class/struct like so: …

c++ memory memory-alignment
Unaligned access causes error on ARM Cortex-M4

I have an object that has an address that is not 4-byte aligned. This causes a HardFault error in the …

c++ c arm memory-alignment cortex-m
best cross-platform method to get aligned memory

Here is the code I normally use to get aligned memory with Visual Studio and GCC inline void* aligned_malloc(…

c++ c performance sse memory-alignment
why is data structure alignment important for performance?

Can someone give me a short and plausible explanation for why the compiler adds padding to data structures in order …

performance alignment memory-alignment abi