| |||||
Technical Support Support Resources
Product Information | C166: __INLINE GENERATES CALL OR WARNING #197Information in this article applies to:
QUESTIONThe __inline keyword does not seem to inline the code in all cases. It looks like code for a subroutine generated and called via CALLS or CALLA. Is this a bug? ANSWERAccording to ANSI-C standard '__inline' is implementation defined. The C166 is not always able to inline a function, or inlining is not done to avoid potential run-time problems. The C166 generally ignores the attribute __inline if the function:
Function in-lining is performed on expression statement boundary where the right side operator is a function call: z = iFunc (z1, z2) // in-lined: first operation is function call z = iFunc (z1, z2) * 11 // not in-lined: first operation is multiplication z = iFunc (z1, z2) + 2; // not in-lined: first operation is addition Expressions of a 'for' statement are never in-lined, for example:
for (z = iFunc (z1, z2) ; z != 0 ; ) { // call to iFunc never in-lined
...
}
An __inline function with no calls (Leaf function) or calls to other Leaf functions is in-lined as long as the above rules are fulfilled.
static __inline int yFunc (int n) {
return (n + 10);
}
static int zFunc (int n) {
return (n + 10);
}
static __inline int iFunc (int i, int y) {
i += y;
i += yFunc (y); // Note: i += yFunc * zFunc (i): not in-lined
i *= zFunc (i);
return (i);
}
static int z, z1, z2;
void main (void) aaaa{
z = iFunc (z1, z2); // in-lined
z = z2 + iFunc (z1, z2); // not in-lined
z = iFunc (z1, z2) * 11; // not in-lined
}
MORE INFORMATION
Last Reviewed: Saturday, May 01, 2004 | ||||
| |||||