结构体初始化 成员变量前加. 是什么意思?
结构体初始化 成员变量前加. 是什么意思?(如.pf = PF_INET,)谢谢
static struct nf_sockopt_ops imp1_sockops =
{
.pf = PF_INET,
.set_optmin = IMP1_SET,
.set_optmax = IMP1_MAX,
.set = data_to_kernel,
.get_optmin = IMP1_GET,
.get_optmax = IMP1_MAX,
.get = data_from_kernel,
};
nf_sockopt_ops的声明如下:
struct nf_sockopt_ops
{
struct list_head list;
int pf;
/* Non-inclusive ranges: use 0/0/NULL to never get called. */
int set_optmin;
int set_optmax;
int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len);
int (*compat_set)(struct sock *sk, int optval,
void __user *user, unsigned int len);
int get_optmin;
int get_optmax;
int (*get)(struct sock *sk, int optval, void __user *user, int *len);
int (*compat_get)(struct sock *sk, int optval,
void __user *user, int *len);
/* Use the module struct to lock set/get code in place */
struct module *owner;
};
[解决办法]
没有见过这个用法,你确认是标准c或者c++的用法?
这个代码是linux下的?
[解决办法]
不懂
up
[解决办法]
http://dev.chinaitzhe.com/c/2008-06/121247738956704.html
http://blog.hjenglish.com/bedford/articles/1078996.html
[解决办法]
C99标准的语法
这样初始化时不必严格按结构成员声明的顺序初始化
可惜C89和C++都不支持该语法