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.

  • 相关阅读:
    第04组 Alpha冲刺 总结
    第04组 Alpha冲刺 (6/6)
    软工实践个人总结
    第09组 每周小结 (3/3)
    第09组 每周小结 (2/3)
    第09组 每周小结 (1/3)
    第09组 Beta冲刺 总结
    第09组 Beta冲刺 (5/5)
    第09组 Beta冲刺 (4/5)
    第09组 Beta冲刺 (3/5)
  • 原文地址:https://www.cnblogs.com/cristiano-duan/p/13281995.html
Copyright © 2011-2022 走看看