Home > OS >  Consulting a LIST_HEAD usage of Linux
Consulting a LIST_HEAD usage of Linux

Time:09-16

RT, recently saw the LIST_HEAD a macro control can initialize the structure, and then they try to under the vs2010 tried, found that no matter how to make up, however, also please bosses answer, why?
The error information is as follows:
1> The error C2086: "the list_head my_list" : redefine
Always said redefinition, really did not understand where to redefine the, no matter what the name change, or redefine,

The test code as follows
#include
#include

Struct list_head {
Next, struct list_head * * prev.
};

# define LIST_HEAD_INIT (name) {& amp; (name), & amp; (name)}

# define LIST_HEAD (name) \
Struct list_head name=LIST_HEAD_INIT (name)

Int main (void)
{
Struct list_head my_list;

The LIST_HEAD (my_list);

Printf (" hell world \ r \ n ");
system("pause");
return 0;

}

CodePudding user response:

Confused, I see,,
Struct list_head my_list;

The LIST_HEAD (my_list);
Spread out the LIST_HEAD macro control
Struct list_head my_list=LIST_HEAD_INIT (my_list)
Is indeed my_list redefines the,, but alas, rollover, this problem was thought for an afternoon, excuse me,,
  • Related