(C/C++) how to create a macro that accepts the increment operator -
to make question precise create macro accepts variable ++ , pastes variable. in code:
#define mymacro(a, op) /* .... */
and if write in source file
mymacro(this->var, ++)
the preprocessor should paste in code
this->var++;
when trying define macro a##op , provides following error:
pasting "++" , "var" not give valid preprocessing token
is possible trying?
thanks in advance answer
you need combine tokens this:
#define mymacro(a, incrdecr) (a)incrdecr
Comments
Post a Comment