Question about a C macro expansion

Posted by holydiver on Stack Overflow See other posts from Stack Overflow or by holydiver
Published on 2010-04-20T08:44:49Z Indexed on 2010/04/20 10:23 UTC
Read the original article Hit count: 163

Filed under:
|
|
|

I generally have ignored using macros while writing in C but I think I know fundamentals about them. While i was reading the source code of list in linux kernel, i saw something like that:

#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
    struct list_head name = LIST_HEAD_INIT(name)

(You can access the remaining part of the code from here.)

I didn't understand the function of ampersands(I don't think they are the address of operands here) in LIST_HEAD_INIT and so the use of LIST_HEAD_INIT in the code. I'd appreciate if someone can enlighten me.

© Stack Overflow or respective owner

Related posts about c

    Related posts about macros