This trick doesn't work if the C/C++ function being called has no args such as a default ctor.
This is from using m4 to preprocess Java. LocalVector3 is macro that expands as a Java class (where typedef would be used in C++). But m4 will interpret the second LocalVector as calling a m4 macro.
m4_define(`LocalVector3’,`Vector3’) ... LocalVector3 v = new LocalVector3( 0.0f, 0.0f, 0.0f );which m4 will incorrectly expand as:
LocalVector3 v = new LocalVector3 ;
A trick is to test whether a macro was written in function call form by testing if args were passed. There are two keys to this trick:
1. The entire second arg to m4_define() is quoted.
2$* is double quoted.
First LocalVector3 is passed args then passed to m4_pushdef().
Hence the double-quotes.
m4_define(LocalVector3,` m4_pushdef(`ARGS’,``$*’’) m4_ifelse(ARGS,,`Vector3’,`Vector3(ARGS)’) m4_popdef(`ARGS’) ’)