在下面的代码中,我试图在 kerenl 模块中创建一个链表,为什么会出现以下错误?
error(in LIST_HEAD(root->list)): expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘->’ token
typedef struct
{
int a;
char* b;
struct list_head list;
}mystruct;
void add(mystruct* r)
{
mystruct* tmp = (mystruct*)vmalloc(sizeof(mystruct));
tmp->a = 110;
tmp->b = (char*)vmalloc(sizeof(char)*10);
list_add_tail(&(tmp->list),&(r->list));
}
int init_module(void)
{
mystruct *root;
LIST_HEAD(root->list);
add(root);
}