[ fromfile: functions.xml id: inlinefunct ]
Such a declaration is a request to the compiler that it replace each call to the function with the fully expanded code of the function.
For example:
inline int max(int a, int b){ return a > b ? a : b ; } int main(){ int temp = max(3,5); etc.... }
The compiler could substitute the expanded code for max
as shown here.
int main() { int temp; { int a = 3; int b = 5; temp = a > b ? a : b; } etc....... }
The substitution process for a #define
macro is handled by the preprocessor, which is essentially a text editor.
The substitution process for an inline
function is handled by the compiler, which will perform the operation much more intelligently with proper type checking.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |