(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

Popular posts from this blog

cron - how to properly run Python script with crontab on every system startup -

elasticsearch - Is the order of operations guaranteed in a bulk update? -

Slow performance first queries on SQL Azure -