Macro is text expansion. In reality, it can be expanded and written to discover errors..
6.1 do not ignore spaces in macro definitions.6.2 When a macro Is Not a function macro defining a function, 1. Enclose each parameter in brackets. 2. Enclose the entire expression. 3. Make sure that the macro parameters have no side effects # define max (A, B) (a)> (B )? (A) (B) max (big, X [I ++]). At this time, ++ may be calculated twice, resulting in side effects. Macros may have side effects due to auto-increment or decrement operations, and may also generate very large expressions.
Eliminate the side effects of if else: # define assert (e) \ (void) (e) | _ assert_error (_ file __,__ line __)))
6.4 macro is not a type definition # define T1 struct Foo * typedef struct Foo * t2
T1 a, B; // declaration is extended to struct Foo * a, B; B is not a pointer. T2 A, B;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service