Macro functions are fast to execute, but occupy a large length of Code and are not easy to debug.
Maxcompute macro functions can be written
#define f(a,b) ((a)+(b))
All the parameters in the macro function should be enclosed in parentheses to ensure that the operations of A and B are completed first. the outermost side of the macro function should be added with parentheses to ensure the overall operation of the macro function.
For complex macro functions that require calling other functions, enclose them with braces to avoid statements such as if and only execute the first sentence.
#define F(a,b) { \ f(a); g(b); }
The backlash is used to meet the requirements of macro functions defined in a row.
However, another problem occurs here. For some statements, such as if (x) f (a, B) else... only one statement in IF is required. If the preceding format is used
if (x) { f(a); f(b);}; else...
An extra semicolon does not conform to the syntax specification. It is obviously two statements that violate the syntax. Therefore, you need to set a statement that can be followed by a semicolon outside the braces. The common one is do {} while (0 );
The final form is:
#define F(a,b) do{ \ f(a); g(b); }while(0)
The expanded form is
if ( x ) do { f(a); f(b); } while(0);else
...
Refer:
Summary of macro c Definition
Http://dxf206.blog.163.com/blog/static/4227861200952511813462/