Alberto Embedded & Open experience

Notes on my experience on Open Source Embedded Systems

Archive for the ‘programming’ Category

C Preprocessor and Macro, symbol ##

leave a comment »

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

Written by Alberto!

01/04/2009 at 1:22 pm

Posted in programming

Tagged with , ,