Here we learn the usage of the Define and inline keywords, and their differences.
Define: Defines a macro that is processed at precompilation time, but simply replaces the string with no type checking .
The inline:1, inline keyword is used to define an inline function of a class, and the main reason for introducing it is to replace the macro definition in the form of the expression in C with the completion of the compilation phase . 2, inline function to do type security check , inline refers to the embed code, in the call function where not jump, but to write directly to the code there, for the short function, the inline function can be a certain increase in efficiency, and the C-era macro function compared to The inline function is more secure and reliable, at the expense of increased space consumption.
PS: Defining an inline function is only a suggestion to the compiler, but the final decision is the compiler, and if the logic of the function is complex (with cyclic recursion), then the inline fails. According to the Google programming specification, inline functions are typically below 10 lines and are logically simple.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Define and inline keyword comparisons