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.

  • 相关阅读:
    ASP.NET Core开发者路线指南(转)
    一文读懂QPS、TPS、PV、UV、GMV、IP、RPS(转)
    后端开发术语大全转
    css 动态设置某一元素随浏览器大小而调整
    .NET FTP上传文件
    bootstrapselectpicker 插件事件
    Node.js安装及环境配置之Windows篇
    EasyUI表单验证插件扩展
    程序员需要知道的缩写和专业名词转
    JavaScript指定日期格式化
  • 原文地址:https://www.cnblogs.com/cristiano-duan/p/13281995.html
Copyright © 2011-2022 走看看