mercoledì 1 aprile 2009

C Preprocessor and Macro, symbol ##

It is easy to see in kernel sources within macros the symbol ## but what it mean??
It is used to Concatenate "token" of text source: when the macro is expanded first the preprocessor substitute the variables name with their values and then concatenate tokens divided by ##
#define init_func(prefix_name, arg) prefix_name##_init(arg)
so calling:
init_func(armadillo, null)
expands in:
armadillo_init(null)
fox!

Reference: http://gcc.gnu.org/onlinedocs/cpp/Concatenation.html#Concatenation

Nessun commento:

Posta un commento