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.

编 译 器 特 有 的 功 能4.3.2 __attribute__((always_inline))此 函 数 属 性 指 示 必 须 内 联 函 数 。编 译 器 将 尝 试 内 联 函 数 , 而 不 考 虑 函 数 的 特 性 。 但 是 , 如 果 这 样 做 导 致 出 现 问题 , 编 译 器 将 不 内 联 函 数 。 例 如 , 递 归 函 数 仅 内 联 到 本 身 一 次 。注 意此 函 数 属 性 是 <strong>ARM</strong> 编 译 器 支 持 的 GNU 编 译 器 扩 展 。 它 具 有 等 效 的 关 键 字__forceinline。示 例static int max(int x, int y) __attribute__((always_inline)){return x > y ? x : y; // always inline if possible}另 请 参 阅• 第 2-58 页 的 --forceinline• 第 4-6 页 的 __forceinline4.3.3 __attribute__((const))很 多 函 数 只 检 查 传 递 给 它 们 的 参 数 , 并 且 只 影 响 返 回 值 。 这 是 一 个 比__attribute__((pure)) 严 格 得 多 的 类 , 因 为 不 允 许 函 数 读 取 全 局 内 存 。 如 果 已 知函 数 只 能 依 靠 其 自 变 量 起 作 用 , 则 可 以 对 其 进 行 公 共 子 表 达 式 删 除 和 循 环 优化 。注 意此 函 数 属 性 是 <strong>ARM</strong> 编 译 器 支 持 的 GNU 编 译 器 扩 展 。 它 具 有 等 效 的 关 键 字__pure。示 例int Function_Attributes_const_0(int b) __attribute__ ((const));int Function_Attributes_const_2(int b){int aLocal=0;aLocal += Function_Attributes_const_0(b);<strong>ARM</strong> DUI 0348BC Copyright © 2007-2009 <strong>ARM</strong> Limited. All rights reserved. 4-33ID090708Non-Confidential, Unrestricted Access

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

Saved successfully!

Ooh no, something went wrong!