Strange macro... Could anyone explain please?

So here is the line of code that I was curious, rather concerned about.

#define PROCESS_NAME(name) extern struct process name

This line is from the source code of Contiki-OS(v2.4), an embedded operating system concentrating on networking etc. I am trying to port it for another platform. For that I must understand all of the code and what's happening in background.

The line of code given above intriugues me. The problem is, it is working, yet I cannot justify how. It is a macro, for declaring name of a process (which resides as a structure in RAM). However, which identifier in the expression is the structure? Is it process? Or name? Or both? Or none?

What on earth does struct process name mean? If it had been struct process, that would have been understandable. If it had been process name, it'd have been justified (considering process was declared as a structure or type earlier). But what do they mean, combined?

I tried to guess. The possibility that I can think of is, there is a structure called process and it has an instance called name... But that doesn't fall into the context.

Please help. Thank you.
Last edited on
closed account (1vRz3TCk)
Contiki-OS has a struct named process, the define declare the name of a process much the same as you may write extern int X.

I tried to guess. The possibility that I can think of is, there is a structure called process and it has an instance called name... But that doesn't fall into the context.


It is exactly that.

In C, the keyword "struct" is required in every variable declaration. C++ does not, so this may have you off balance here. This is why the Windows API defines all structs inside a typedef, so the keyword "struct" is not necessary even in C.
Thank you.

Good to know I have some sanity left in me to make correct guesses. I bet that would be gone, too, once I am done with this OS work. :)
Topic archived. No new replies allowed.