您的位置:首页 > 理论基础 > 数据结构算法

宏:集中定义,多次使用

2012-08-29 10:48 120 查看
1:集中定义

#include <ci/internal/opts_netif_def.h>:

CI_CFG_OPT("", tcp_sndbuf_min, ci_uint32,

"Minimum value for SO_SNDBUF for TCP sockets.  Set via O/S interface.",

           ,  tcp_sndbuf, CI_CFG_TCP_SNDBUF_MIN, MIN, MAX, bincount)

2:使用其为数据结构:

typedef struct {

  /* These fields are defined in a separate file that is also used by the

  ** configuration subsystem

  */

#define _CI_CFG_BITFIELD

#define _CI_CFG_BITFIELD1  :1

#define _CI_CFG_BITFIELD2  :2

#define _CI_CFG_BITFIELD3  :3

#define _CI_CFG_BITFIELD4  :4

#define _CI_CFG_BITFIELD8  :8

#define _CI_CFG_BITFIELD16 :16

#define _CI_CFG_BITFIELDA8 CI_ALIGN(8)

    

#undef CI_CFG_OPTFILE_VERSION

#undef CI_CFG_OPT

#undef CI_CFG_OPTGROUP

#define CI_CFG_OPTFILE_VERSION(version)

#define CI_CFG_OPTGROUP(group, category, expertise)

#define CI_CFG_OPT(env, name, type, doc, bits, group, default, min, max, presentation) \

        type name _CI_CFG_BITFIELD##bits;

#include <ci/internal/opts_netif_def.h>

    

    ci_boolean_t inited;

} ci_netif_config_opts;

ci_netif_config_opts is:

typedef struct {

    ci_uint32 tcp_sndbuf_min;

}

3:使用其为赋值:

ci_netif_config_opts* opts;

# undef  CI_CFG_OPTFILE_VERSION

# undef  CI_CFG_OPTGROUP

# undef  CI_CFG_OPT

# define CI_CFG_OPT(env, name, type, doc, type_modifider, group,     \

                    default, minimum, maximum, presentation)          \

  opts->name = default;

# include <ci/internal/opts_netif_def.h>

opt->tcp_sndbuf_min = CI_CFG_TCP_SNDBUF_MIN;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐