https://github.com/gongluck/Windows-Core-Program.git
//第13章 内存体系结构.cpp: 定义应用程序的入口点。
//
#include "stdafx.h"
#include "第13章 内存体系结构.h"
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
WORD w;
PVOID test = &w;
char c = *(PBYTE)test;
//访问错位数据
test = (PBYTE)&w + 1;
DWORD d = *(UNALIGNED PDWORD)test;//UNALIGNED在x86平台无效
if ((int)&d % sizeof(d) == 0)
OutputDebugString(TEXT("***********对齐***********\n"));
else
OutputDebugString(TEXT("***********未对齐***********\n"));
system("pause");
return 0;
}
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有