function attributes, MDK
__attribute__((attribute1,attribute2, ...))
__attribute__((__attribute1__,__attribute2__, ...))
void * Function_Attributes_malloc_0(int b) __attribute__((malloc));
static int b __attribute__((__unused__));
Table 9-3 Function attributes that the compiler supports, and their equivalents
| Function attribute | Non-attribute equivalent |
|---|---|
__attribute__((alias)) |
- |
__attribute__((always_inline)) |
__forceinline |
__attribute__((const)) |
__pure |
__attribute__((constructor[( |
- |
__attribute__((deprecated)) |
- |
__attribute__((destructor[( |
- |
__attribute__((format_arg( |
- |
__attribute__((malloc)) |
- |
__attribute__((noinline)) |
__declspec(noinline) |
__attribute__((no_instrument_function)) |
- |
__attribute__((nomerge)) |
- |
__attribute__((nonnull)) |
- |
__attribute__((noreturn)) |
__declspec(noreturn)) |
__attribute__((notailcall)) |
- |
__attribute__((pcs(" |
- |
__attribute__((pure)) |
- |
__attribute__((section(" |
- |
__attribute__((unused)) |
- |
__attribute__((used)) |
- |
__attribute__((visibility(" |
- |
__attribute__((weak)) |
__weak |
__attribute__((weakref("target"))) |
- |
Usage
void AddGlobals(void) __attribute__((always_inline));
__attribute__((always_inline)) void AddGlobals(void) {...}
__attribute__((used)) is safer than __attribute__((unused)), and __attribute__((noinline)) is safer than __attribute__((always_inline)).1. __attribute__((alias))
Examples
#include <stdio.h>
void foo(void)
{
printf("%s\n", __FUNCTION__);
}
void bar(void) __attribute__((alias("foo")));
void gazonk(void)
{
bar(); // calls foo
}
2. __attribute__((always_inline))
此函数属性指示函数必须内联。无论函数的特征如何,编译器都会尝试内联该函数。但是,如果这样做会导致问题,编译器不会内联函数。例如,递归函数只内联一次。
这个函数属性是ARM编译器支持的GNU编译器扩展。它具有相当__forceinline关键字。
Examples
static int max(int x, int y) __attribute__((always_inline));
static int max(int x, int y)
{
return x > y ? x : y; // always inline if possible
}
3. __attribute__((const))
许多函数只检查传递给它们的参数,除了返回值没有作用。这是一个比__attribute__((pure))更严格的等级,因为允许读取全局内存是不是一个函数。如果已知函数只对其参数进行操作,则它可能受到常见的子表达式消除和循环优化的影响。
此函数属性是ARM编译器支持的GNU编译器扩展。它的关键字等效_pure
int Function_Attributes_const_0(int b) __attribute__((const));
int Function_Attributes_const_0(int b)
{
int aLocal=;
aLocal += Function_Attributes_const_0(b);
aLocal += Function_Attributes_const_0(b);
return aLocal;
}
在此代码中,可能只调用一次函数_properties_const_0,结果加倍以获得正确的返回值。
4.
function attributes, MDK的更多相关文章
- Uboot命令U_BOOT_CMD分析
其中U_BOOT_CMD命令格式如下: U_BOOT_CMD(name,maxargs,repeatable,command,"usage","help") 各 ...
- Backbone源码分析(二)
在传统MVC框架模式中,Model承担业务逻辑的任务.Backbone作为一个mvc框架,主要的业务逻辑交由Model与Collection来实现.Model代表领域对象,今天主要学一下Model源码 ...
- RequireJS与Backbone简单整合
前言 昨天我们一起学习了Backbone,最后做了一个备忘录的例子,说是做了不如说是看了下官方提供的例子,所以最终我感觉我们还是没能掌握Backbone,今天还得做个其它例子先. 然后前面也只是草草学 ...
- 前端MVC框架Backbone 1.1.0源码分析(二) - 模型
模型是什么? Models are the heart of any JavaScript application, containing the interactive data as well a ...
- 用backbone实现的一个MVC的小demo
一.Apache配置 本实例需要使用php支持.要现在Apache中配置虚拟目录,在Apache下的httpd-vhosts.conf文件中添加如下代码 <VirtualHost *:80> ...
- Backbone源码阅读手记
Backbone.js是前端的MVC框架,它通过提供模型Models.集合Collection.视图Veiew赋予了Web应用程序分层结构.从源码中可以知道,Backbone主要分了以下几个模块: ( ...
- __attribute__
转来的: http://www.cnblogs.com/astwish/p/3460618.html __attribute__ 你知多少? GNU C 的一大特色就是__attribute__ 机制 ...
- Programming Entity Framework 翻译(1)-目录
1. Introducing the ADO.NET Entity Framework ado.net entity framework 介绍 1 The Entity Relationship Mo ...
- 【转】Backbone使用总结
转自 http://www.pchou.info/javascript/2014/06/26/backbone-summary-01.html 开始在项目中大规模使用backbone,一路磕磕碰碰, ...
随机推荐
- App应用推广
Android应用推广渠道: 360手机助手: http://dev.360.cn/ 应用宝: http://open.qq.com/ 百度手机助手: http://shouji.baidu.com/ ...
- 使用python发送163邮件 qq邮箱
使用python发送163邮件 def send_email(title, content): import smtplib from email.mime.multipart import MIME ...
- (9)centos7 安装与解压
1.zip/unzip zip 新file 旧file或文件夹 # 把旧文件和文件夹压缩成新文件 -r是文件夹下所有文件 zip -r a.zip ./doc #压缩当前目录 doc下的所有文件变成 ...
- hbase之setCaching 和 setBatch 和setMaxResultSize
scan的setBatch()用法 val conf = HBaseConfiguration.create() val table: Table = ConnectionFactory.create ...
- JMeter AI图片识别接口并发量测试
由于临时接到一个性能测试任务,测试8个独立接口在实验室环境的TPS.响应时间以及服务器性能监控如CPU.内存.IO等,没有明确具体的响应时间与并发数,需求较模糊. 1.软件.硬件环境信息:JMeter ...
- Java的核心优势
Java为消费类智能电子产品而设计,但智能家电产品并没有像最初想象的那样拥有大的发展.然而90年代,Internet却进入了爆发式发展阶段,一夜之间,大家都在忙着将自己的计算机连接到网络上.这个时侯, ...
- js小项目:显示与输入的内容相关的
1,添加键盘抬起事件 2,获取文本框的内容,是否与数组中的内容匹配 3,创建元素 <!DOCTYPE html> <html lang="en"> < ...
- 关于py中lxml模块的cssselect的小问题
今天在使用lxml进行解析页面的时候遇到了不能解析空格的问题,就是类似于: <div class="aa bb"></div> 使用cssselect('. ...
- swagger2 注解说明 ( @ApiImplicitParams )
@Api:用在请求的类上,表示对类的说明 tags="说明该类的作用,可以在UI界面上看到的注解" value="该参数没什么意义,在UI界面上也看到,所以不需要配置&q ...
- 2019-9-18-WPF-客户端开发需要知道的触摸失效问题
title author date CreateTime categories WPF 客户端开发需要知道的触摸失效问题 lindexi 2019-09-18 15:30:38 +0800 2019- ...