ARM Technical Support Knowledge Articles


Applies to: C166 C Compiler


Information in this article applies to:


The __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?


According 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


Article last edited on: 2004-05-01 21:13:27

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential