10.07.2015 Views

MPLAB® C30 C 编译器用户指南

MPLAB® C30 C 编译器用户指南

MPLAB® C30 C 编译器用户指南

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

MPLAB <strong>C30</strong> 与 ANSI C 的 差 别2.3.2 指 定 函 数 的 属 性在 MPLAB <strong>C30</strong> 中 , 可 以 对 程 序 中 调 用 的 函 数 进 行 某 些 声 明 , 帮 助 编 译 器 优 化 函 数 调用 , 且 更 准 确 地 检 查 代 码 。关 键 字 _attribute_ 允 许 在 声 明 时 指 定 特 殊 的 属 性 。 关 键 字 后 面 紧 跟 双 括 弧 中 的 属性 说 明 。 目 前 支 持 函 数 的 下 列 属 性 :• address (addr)• alias ("target")• const• deprecated• far• format (archetype, string-index, first-to-check)• format_arg (string-index)• near• no_instrument_function• noload• noreturn• section ("section-name")• shadow• unused• weak我 们 也 可 以 通 过 在 关 键 字 前 后 使 用 __ ( 双 下 划 线 ) 来 指 定 属 性 ( 例 如 , 用__shadow __ 代 替 shadow)。 这 样 使 得 在 头 文 件 中 使 用 它 们 时 不 必 考 虑 会 出 现 与 宏同 名 的 情 况 。我 们 要 想 在 声 明 中 指 定 多 个 属 性 , 可 以 在 双 括 弧 内 使 用 逗 号 将 属 性 分 隔 开 , 或 者 在 一个 属 性 声 明 后 紧 跟 另 一 个 属 性 声 明 。address (addr)address 属 性 为 函 数 指 定 绝 对 地 址 。 这 个 属 性 不 能 与 section 属 性 同 时 使 用 ;address 属 性 优 先 。void foo() __attribute__ ((address(0x100))) {...}alias ("target")alias 属 性 为 另 一 个 符 号 声 明 一 个 别 名 , 必 须 指 定 这 个 符 号 。使 用 这 一 属 性 会 产 生 对 对 象 的 外 部 引 用 , 必 须 在 链 接 时 解 析 该 引 用 。© 2005 Microchip Technology Inc. DS51284C_CN 第 19 页

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

Saved successfully!

Ooh no, something went wrong!