reality displays
reality displays

Reputation: 751

macro initialization not clear

I am not clear with following code

struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);

this can be seen here http://lxr.free-electrons.com/source/kernel/nsproxy.c?v=2.6.28#L27

I am not able to understand the use of macro INIT_NSPROXY which is here http://lxr.free-electrons.com/source/include/linux/init_task.h?v=2.6.28#L53

the macro is defined to use INIT_NSPROXY(nsproxy) but when the above snippet is initializing then it is using INIT_NSPROXY(init_nsproxy) how is that possible?

Upvotes: 0

Views: 162

Answers (2)

hopia
hopia

Reputation: 5006

In this form, you can think of the macro as a function call. The name of the function is INIT_NSPROXY, and the name of the parameter is nsproxy. Inside the INIT_NSPROXY macro, nsproxy is replaced by whatever identifier was passed to it.

Upvotes: 0

James McNellis
James McNellis

Reputation: 355079

#define INIT_NSPROXY(nsproxy) // etc.

In this macro definition, nsproxy is the name of the parameter to the macro.

In the macro replacement list (everything on the line after the #define INIT_NSPROXY(nsproxy) part), anywhere that the nsproxy token appears, it is replaced by whatever argument is passed.

In this case, the argument init_nsproxy is being passed.

Upvotes: 1

Related Questions