I don\'t know if that is possible, I want to pass a block of instructions in macro like an argument.I will show you an example:
#define ADD_MACRO(size, BLOCK){ f
The only problem with the given macro is that it doesn't handle commas in the BLOCK
. Commas are tolerated by a variadic macro parameter:
#define ADD_MACRO(size, ...) do { for(int i=0; i
(Also, common practice is to enclose statement macros in do … while(0)
to force the user to include a semicolon.)
(Of course, the original problem may have a better solution. The preprocessor is a blunt instrument. This is the preprocessor solution to the stated question.)