当前位置:网站首页>byte alignment
byte alignment
2022-07-03 09:52:00 【0725 you Guangchuan】
Byte alignment :
If it takes N Bytes , His starting address must be N Integer multiple ; namely : Initial address %N=0;
Structure alignment
The structure is aligned with the largest member : Initial address %N=0;( The starting address of the structure is an integer multiple of the widest member type )
pragma pack(N)
When the space requirements are relatively high , Can pass #pragma pack(N) To change the alignment of structure members
e.g #pragma pack(1)
struct Test {
char b;
int a;
}
#pragma pack()// Unalign
(1)#pragma pack() You can set N Byte alignment (1,2,4,8 VC Compiler defaults 8)
N=min( The maximum occupied bytes of structure members , Align bytes )
Calculate the size of the structure as N Integer multiple
#prgma pack(1,2,4,8)
typedef struct
{
char a;
int b;
char ;
}
#pragma pack () The starting address of the structure is 4 Integer multiple ( namely Initial address %4 =0)
Total size of structure :N = Min( The largest member , Alignment parameters )
yes N Integer multiple
边栏推荐
- The cyclic shift of PUCCH in NR channel is generated by MATLAB
- Leetcode daily question (2232. minimize result by addressing parents to expression)
- Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 4 --blinker_ DHT_ WiFi (lighting technology app control + temperature and humidity data app display)
- 对于新入行的同学,如果你完全没有接触单片机,建议51单片机入门
- Nr-prach:prach format and time-frequency domain
- Design and development of biological instruments
- Difference of EOF
- All processes of top ten management in project management
- 嵌入式系统没有特别明确的定义
- PIP references domestic sources
猜你喜欢
STM32 port multiplexing and remapping
Runtime. getRuntime(). GC () and runtime getRuntime(). The difference between runfinalization()
Shell logic case
Flink learning notes (VIII) multi stream conversion
一个可执行的二进制文件包含的不仅仅是机器指令
STM32 serial communication principle
Fundamentals of Electronic Technology (III)_ Chapter 2 principle of amplification circuit__ Crystal triode and field effect triode
[CSDN] C1 training problem analysis_ Part II_ Web Foundation
When you need to use some functions of STM32, but 51 can't realize them, 32 naturally doesn't need to learn
Project cost management__ Topic of comprehensive calculation
随机推荐
Getting started with shell programming
Leetcode daily question (2090. K radius subarray averages)
Mysql database underlying foundation column
Fundamentals of Electronic Technology (III)__ Chapter 1 resistance of parallel circuit
Global KYC service provider advance AI in vivo detection products have passed ISO international safety certification, and the product capability has reached a new level
学历是一张通行证,门票,你有了它,可以踏入更高层次的环境里
[successful graduation] [1] - visit [student management information system]
Fundamentals of Electronic Technology (III)__ Chapter 6 combinational logic circuit
[csdn] C1 analyse des questions de formation Partie III Bar _ JS Foundation
Flink CDC practice (including practical steps and screenshots)
Leetcode daily question (2232. minimize result by addressing parents to expression)
Nr--- Pusch I: sorting out the agreement process
QT qcombobox QSS style settings
Leetcode daily question (1856. maximum subarray min product)
Introduction to chromium embedded framework (CEF)
Eight working modes of stm32gpio and chip naming rules
CEF下载,编译工程
The number of weak characters in the game (1996)
Electronic product design, MCU development, circuit cloning
[CSDN]C1訓練題解析_第三部分_JS基礎