How to make the first invocation of a macro different from all the next ones ?

Posted by LB on Stack Overflow See other posts from Stack Overflow or by LB
Published on 2010-03-15T14:31:54Z Indexed on 2010/03/15 15:19 UTC
Read the original article Hit count: 129

Filed under:
|
|

Hi,

that may be really simple but i'm unable to find a good answer. How can I make a macro representing first a certain value and then a different one ?

I know that's nasty but i need it to implicitly declare a variable the first time and then do nothing. This variable is required by other macros that i'm implementing.

Should i leverage "argument prescan" ?

thanks for the answers.

EDIT To make things clearer. Suppose i have a macro FOO, and I do something like

FOO
FOO
FOO

I would like the result to be

foo
bar
bar   

I don't want the actual code to be cluttered by ifndef. The programmer should only have to write macro invocations.

© Stack Overflow or respective owner

Related posts about c

    Related posts about preprocessor