Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 看起来无用的宏参数的用途是什么(参见下面的代码)_C_Macros_Bsd - Fatal编程技术网

C 看起来无用的宏参数的用途是什么(参见下面的代码)

C 看起来无用的宏参数的用途是什么(参见下面的代码),c,macros,bsd,C,Macros,Bsd,在BSD系统的头文件queue.h中,有以下宏 #define TAILQ_ENTRY(type, qual)\ struct {\ qual type *tqe_next; /* next element */\ qual type *qual *tqe_prev; /* address of previous next element */\ } 根据上述定义,人们应该像这样使用它 struct foo { TAILQ_ENTRY(struct fo

在BSD系统的头文件queue.h中,有以下宏

#define TAILQ_ENTRY(type, qual)\
struct {\
    qual type *tqe_next;        /* next element */\
    qual type *qual *tqe_prev;  /* address of previous next element */\
}
根据上述定义,人们应该像这样使用它

struct foo {
    TAILQ_ENTRY(struct foo, ) my_list;
    //some data here
};
我的问题是:宏参数“qual”在这里的作用是什么,它似乎在生成的代码中不起任何作用。

好吧,在您的使用中,它可能未被使用,但可以像这样进行一次调用

struct foo {
TAILQ_ENTRY(struct foo, ) my_list;
TAILQ_ENTRY(struct foo, const) my_list_too;
//some data here
};
其中
const
是类型限定符

类型限定符可以是
const
restrict
volatile
\u-Atomic
那么,在您的使用中,它可能未使用,但可以像这样进行一次调用

struct foo {
TAILQ_ENTRY(struct foo, ) my_list;
TAILQ_ENTRY(struct foo, const) my_list_too;
//some data here
};
其中
const
是类型限定符


类型限定符可以是
const
restrict
volatile
\u Atomic

在大多数情况下,使用宏进行类型定义是非常可疑的做法。在大多数情况下,使用宏进行类型定义是非常可疑的做法。