zoukankan      html  css  js  c++  java
  • __attribute__((destructor)) 修饰函数

    __attribute__可以设置函数属性(Function Attribute)、变量属性(Variable Attribute)和类型属性(Type Attribute)。__attribute__前后都有两个下划线.

    __attribute__语法格式为 __attribute__ ( ( attribute-list ) )$

    若函数被设定为constructor属性,则该函数会在main()函数执行之前被自动的执行。类似的,若函数被设定为destructor属性,则该函数会在main()函数执行之后或者exit()被调用后被自动的执行。

    关键字__attribute__允许你声明时指定特殊的属性。这个关键字后面跟着双层括号引起来的属性说明。目前定义用于函数的属性:

    aligned
    alloc_size 
    alloc_align
    assume_aligned
    noreturn
    returns_twice
    noinline
    noclone
    no_icf
    always_inline
    flatten
    pure
    const
    nothrow
    sentinel
    format
    format_arg
    no_instrument_function
    no_split_stack
    section
    constructor
    destructor
    used
    unused
    deprecated
    weak
    malloc
    alias
    ifunc
    warn_unused_result
    nonnull
    returns_nonnull
    gnu_inline
    externally_visible
    hot
    cold
    artificial
    no_sanitize_address
    no_address_safety_analysis
    no_sanitize_thread
    no_sanitize_undefined
    no_reorder
    bnd_legacy
    bnd_instrument
    stack_protect
    error
    warning
    Other attributes, including section are supported for variables declarations, labels and for types.
    

    You may also specify attributes with ‘__’ preceding and following each keyword. This allows you to use them in header files without being concerned about a possible macro of the same name. For example, you may use noreturn instead of noreturn.

  • 相关阅读:
    简单批处理内部命令简介(转)
    CPU 内存 频率 DDR DDR2 DDR3
    python 正则表达式
    bat 脚本 > >> 管道
    python 多进程 无数进程 重复进程 死机
    NLP相关期刊和会议
    deamon tools dtsoft virtual cdrom device 失败 错误
    占位
    2011年07月03日的日记
    每周总结(第二周)
  • 原文地址:https://www.cnblogs.com/cristiano-duan/p/13281995.html
Copyright © 2011-2022 走看看