C语言学习笔记--__attribute__概述

    GNU C 的一大特色就是__attribute__ 机制。__attribute__ 可以设置函数属性(Function Attribute )、变量属性(Variable Attribute )和类型属性(Type Attribute )。
    语法格式:__attribute__ ((attribute-list)) attribute前后都有两个下划线,并切后面会紧跟一对原括弧,括弧里面是相应的__attribute__ 参数。
    位置:放于声明的尾部“ ;” 之前。
    1、函数属性(Function Attribute)  函数属性可以把一些特性添加到函数声明中,从而可以使编译器在错误检查方面的功能更强大。
    noreturn
    noinline
    always_inline
    pure
    const
    nothrow
    sentinel
    format
    format_arg
    no_instrument_function
    section
    constructor
    destructor
    used
    unused
    deprecated
    weak
    malloc
    alias
    warn_unused_result
    nonnull
    2、类型属性(Type Attributes):
    aligned
    packed
    transparent_union,
    unused,
    deprecated
    may_alias
   3、变量属性(Variable Attribute):
    aligned
    packed
   4、Clang特有:
    availability
    overloadable

猜你喜欢

转载自blog.csdn.net/tyustli/article/details/86261012