c++ - A question about static syntax
習慣沉默
習慣沉默 2017-06-30 09:56:42
0
3
914

I will try my best to describe the problem clearly. If there is anything unclear, please leave a message and I will reply as soon as possible.
The following statement form is available:

 typedef struct mr_dup_ops
    {
        /* 查询镜像状态 */
        int32_t (*dup_mirror_state_query)(uint32_t, mr_kern_mirror_state_query_req_t*);
        ……………………
        ……………………
      
    } mr_dup_owner_ops_t;

Then declare

STATIC mr_dup_owner_ops_t g_local_mr_dup_ops = {
    .dup_mirror_state_query        = mr_ioctl_kern_mirror_state_query,
    ………………
    ………………
    };

Then assuming there is a pointer ops of mr_dup_owner_ops_t, you can access the function mr_ioctl_kern_mirror_state_query through ops->dup_mirror_state_query.

I can understand that the structure mr_dup_owner_ops_t declares a set of function pointers, then add the STATIC structure. Structure name ={.dup_mirror_state_query. What form is this?

習慣沉默
習慣沉默

reply all(3)
我想大声告诉你

Just declare the scope of the variable g_local_mr_dup_ops to be static. What macro should STATIC be? The keywords in C/C++ are in lowercase.

学习ing

static structure A variable a = { ..... }

Define a variable a of type A, static attribute, and initialize it using {....}

Peter_Zhu

The syntax of the initialization part is an extension of gcc, called Designated Initializers.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!