In C++, we can specify the alignment of a type in memory. For example, use __attribute__((aligned(4)))
to align variables of this type with 4Byte. Generally, there are two main points to discuss the role of memory alignment:
- Cross-platform porting (related to hardware)
- Improve CPU access performance
This article is transferred from https://imcbc.cn/202211/tagged-pointer/
This site is only for collection, and the copyright belongs to the original author.