宏:集中定义,多次使用

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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值