Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable name from macro argument

I'd like to do something like this:

class SomeClass { };  GENERATE_FUNTION(SomeClass) 

The GENERATE_FUNCTION macro I'd like to define a function whose name is to be determined by the macro argument. In this case, I'd like it to define a function func_SomeClass. How can that be done?

like image 870
Paul Manta Avatar asked Sep 26 '11 21:09

Paul Manta


1 Answers

#define GENERATE_FUNCTION(Argument) void func_##Argument(){ ... } 

More information here: http://en.wikipedia.org/wiki/C_preprocessor#Token_concatenation

like image 170
K-ballo Avatar answered Sep 28 '22 05:09

K-ballo