10.07.2015 Views

MPLAB® C30 C 编译器用户指南

MPLAB® C30 C 编译器用户指南

MPLAB® C30 C 编译器用户指南

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

MPLAB ® <strong>C30</strong> 用 户 指 南2.3.1 指 定 变 量 的 属 性MPLAB <strong>C30</strong> 的 关 键 字 __attribute__ 用 来 指 定 变 量 或 结 构 位 域 的 特 殊 属 性 。 关 键字 后 的 双 括 弧 中 的 内 容 是 属 性 说 明 。 下 面 是 目 前 支 持 的 变 量 属 性 :• address (addr)• aligned (alignment)• deprecated• far• mode (mode)• near• noload• packed• persistent• reverse (alignment)• section ("section-name")• sfr (address)• space (space)• transparent_union• unordered• unused• weak也 可 以 通 过 在 关 键 字 前 后 使 用 __ ( 双 下 划 线 ) 来 指 定 属 性 ( 例 如 , 用 __aligned__ 代 替 aligned)。 这 样 将 使 您 在 头 文 件 中 使 用 它 们 时 不 必 考 虑 会 出 现 与 宏 同 名 的 情况 。要 指 定 多 个 属 性 , 可 在 双 括 弧 内 用 逗 号 将 属 性 分 隔 开 , 例 如 :__attribute__ ((aligned (16), packed))address (addr)address 属 性 为 变 量 指 定 绝 对 地 址 。 这 个 属 性 不 能 与 section 属 性 同 时 使 用 ;address 属 性 优 先 。 带 address 属 性 的 变 量 不 能 存 放 到 _psv 空 间 ( 参 见 space() 属性 或 -mconst-in-code 选 项 ); 这 样 做 会 产 生 警 告 , 且 编 译 器 将 此 变 量 存 放 到 psv空 间 。如 果 要 将 变 量 存 放 到 PSV 段 , 地 址 应 为 程 序 存 储 器 地 址 。int var __attribute__ ((address(0x800)));DS51284C_CN 第 12 页© 2005 Microchip Technology Inc.

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

Saved successfully!

Ooh no, something went wrong!