Compare the similarities and differences between parameters with macros and functions
From http://blog.csdn.net/piaojun_pj/article/details/5932639
The compiler processes Macros in the pre-compilation phase of the program. It mainly replaces Macros in the source file with pre-compilation commands.
1. Macros will be replaced simply when the compiler compiles the source code, without any logic detection, that is, simple code replication.
2. When macro is defined, the parameter type is not considered.
3. The use of the parameter Macro will make multiple copies of the same code block in the target file, which will increase the size of the target file.
4. The parameter macro runs faster than the function because the parameter pressure stack/out stack operation is not required.
5. Be careful when defining the parameter macro and add brackets.
6. Only one function exists in the target file, saving program space.
7. function calls involve parameter transfer and stack/output operations, which are relatively slow.
8. The function parameter has the problem of passing values and passing addresses (pointers), and the parameter macro does not exist.
Compare the similarities and differences between parameters with macros and functions
From http://blog.csdn.net/piaojun_pj/article/details/5932639
The compiler processes Macros in the pre-compilation phase of the program. It mainly replaces Macros in the source file with pre-compilation commands.
1. Macros will be replaced simply when the compiler compiles the source code, without any logic detection, that is, simple code replication.
2. When macro is defined, the parameter type is not considered.
3. The use of the parameter Macro will make multiple copies of the same code block in the target file, which will increase the size of the target file.
4. The parameter macro runs faster than the function because the parameter pressure stack/out stack operation is not required.
5. Be careful when defining the parameter macro and add brackets.
6. Only one function exists in the target file, saving program space.
7. function calls involve parameter transfer and stack/output operations, which are relatively slow.
8. The function parameter has the problem of passing values and passing addresses (pointers), and the parameter macro does not exist.