zoukankan      html  css  js  c++  java
  • [strongswan] strongswan METHOD宏

    使用METHOD宏的函数定义:

    METHOD(message_t, get_message_id, uint32_t,                                         
            private_message_t *this)                                                    
    {                                                                                   
            return this->message_id;                                                    
    }     

    METHOD宏的定义:

    /**                                                                             
     * Method declaration/definition macro, providing private and public interface. 
     *                                                                              
     * Defines a method name with this as first parameter and a return value ret,   
     * and an alias for this method with a _ prefix, having the this argument       
     * safely casted to the public interface iface.                                 
     * _name is provided a function pointer, but will get optimized out by GCC.     
     */                                                                             
    #define METHOD(iface, name, ret, this, ...)                                    
            static ret name(union {iface *_public; this;}                          
            __attribute__((transparent_union)), ##__VA_ARGS__);                    
            static typeof(name) *_##name = (typeof(name)*)name;                    
            static ret name(this, ##__VA_ARGS__)  

    将METHOD宏展开后的定义:

    static uint32_t get_message_id(union {message_t *_public; private_message_t *this;} __attribute__((transparent_union))); 
    static typeof(get_message_id)* _get_message_id = (typeof(get_message_id)*)get_message_id; 
    static uint32_t get_message_id(private_message_t *this)  

    关于transparent_union的定义:

    http://nanjingabcdefg.is-programmer.com/categories/5966/posts

  • 相关阅读:
    Hadoop学习笔记
    Hadoop学习笔记 -伪分布式
    SSH 连接报错总结
    Hadoop学习笔记
    Trie 前缀树/字典树
    解数独(Leetcode-37 / HDU-1426)/回溯/状态压缩
    MyBatis 多表关联查询
    python_37期自动化【lemon】
    api课堂笔记_day14
    api课堂笔记_day12&day13
  • 原文地址:https://www.cnblogs.com/hugetong/p/10131331.html
Copyright © 2011-2022 走看看