12.07.2015 Views

RealView 编译工具编译器参考指南 - ARM Information Center

RealView 编译工具编译器参考指南 - ARM Information Center

RealView 编译工具编译器参考指南 - ARM Information Center

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

编 译 器 特 有 的 功 能• 没 有 定 义 对 __packed 进 行 类 型 转 换 所 产 生 的 影 响 。 也 没 有 定 义 将 非 压 缩 结构 类 型 转 换 为 压 缩 结 构 类 型 所 产 生 的 影 响 。 可 以 合 法 地 将 指 向 整 型 的 指 针类 型 显 式 或 隐 式 转 换 为 指 向 压 缩 整 型 的 指 针 类 型 。 也 可 以 对 char 类 型 进 行__packed 类 型 转 换 。• 不 存 在 压 缩 数 组 类 型 。 压 缩 数 组 是 指 具 有 压 缩 类 型 的 对 象 数 组 。 数 组 中 没有 进 行 填 充 。示 例示 例 4-4 说 明 指 针 可 以 指 向 压 缩 类 型 。示 例 4-4 指 向 压 缩 类 型 的 指 针typedef __packed int* PpI; /* pointer to a __packed int */__packed int *p; /* pointer to a __packed int */PpI p2; /* 'p2' has the same type as 'p' *//* __packed is a qualifier *//* like 'const' or 'volatile' */typedef int *PI; /* pointer to int */__packed PI p3; /* a __packed pointer to a normal int *//* -- not the same type as 'p' and 'p2' */int *__packed p4; /* 'p4' has the same type as 'p3' */示 例 4-5 说 明 了 使 用 指 针 访 问 压 缩 对 象 时 , 编 译 器 可 生 成 有 效 代 码 , 并 且 代 码与 指 针 对 齐 方 式 无 关 。示 例 4-5 压 缩 结 构typedef __packed struct{char x;// all fields inherit the __packed qualifierint y;} X; // 5 byte structure, natural alignment = 1int f(X *p){return p->y;// does an unaligned read}typedef struct{short x;char y;__packed int z;// only pack this fieldchar a;4-12 Copyright © 2007-2009 <strong>ARM</strong> Limited. All rights reserved. <strong>ARM</strong> DUI 0348BCNon-Confidential, Unrestricted AccessID090708

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!