"Sputnik" help  
Sputnik Help
Language Reference - Preprocessor - Macro Pitfalls - Misnesting

Misnesting

When a macro is called with arguments, the arguments are substituted into the macro body and the result is checked, together with the rest of the input file, for more macro calls. It is possible to piece together a macro call coming partially from the macro body and partially from the arguments. For example,

#define TWICE(x) (2*(x))
#define CALL_WITH_1(x) x(1)
say CALL_WITH_1(TWICE);
            // twice(1)
            // (2*(1))

Macro definitions do not have to have balanced parentheses. By writing an unbalanced open parenthesis in a macro body, it is possible to create a macro call that begins inside the macro body but ends outside of it. For example,

#define STRANGE() printf("%s %d",
STRANGE() "Cat", 35);
// PRINTS
// Cat 35

The ability to piece together a macro call can be useful, but the use of unbalanced open parentheses in a macro body is just confusing, and should be avoided.


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org