zoukankan      html  css  js  c++  java
  • Objective-C 源码初探 __attribute__

    #import <Foundation/Foundation.h>
    
    //延迟执行,delayFunc函数即为延迟执行的函数
    #define onExit
        __strong void (^block)() __attribute__((cleanup(delayFunc),unused)) = ^
    
    void delayFunc(__strong void (^*block)()){
        (*block)();
    }
    
    //在main函数执行之前执行的函数
    __attribute__((constructor)) void ExecuteBefore_main(){
        printf("ExecuteBefore_main
    ");
    }
    
    __attribute__((destructor)) void ExecuteAfter_main(){
        printf("ExecuteAfter_main
    ");
    }
    
    //函数可用性
    void functionDeprecatedAndObsoleteWarningAndError() __attribute__ ((availability(macosx,introduced=10.4,deprecated=10.10,obsoleted=10.13)));
    
    void functionDeprecatedAndObsoleteWarningAndError(void){
        
    }
    
    //返回值未使用
    int returnValueNotUnusedWarning() __attribute__ ((warn_unused_result));
    
    int returnValueNotUnusedWarning(){
        return 1;
    }
    
    int main(int argc, const char * argv[]) {
        @autoreleasepool {
            
            printf("Hello, World!
    ");
            
            functionDeprecatedAndObsoleteWarningAndError();
            returnValueNotUnusedWarning();
            onExit{
                printf("onExit
    ");
            };
        }
        return 0;
    }
  • 相关阅读:
    仿美团pc,koa+ssr(四)
    基本的数据库操作脚本
    jQuery选择器总结
    经常学习参考网站
    WebAPI
    Sqlserver 基本面试题
    truncate和delete的区别
    Webservice,WCF,WebAPI 之间的区别
    WCF 学习
    学习angularJs(1)--引用文件
  • 原文地址:https://www.cnblogs.com/ficow/p/5631461.html
Copyright © 2011-2022 走看看