ARM Technical Support Knowledge Articles

RE-USING INLINE FUNCTIONS

Applies to: C166 C Compiler

Answer


Information in this article applies to:


QUESTION

How can I call an inline function from several different C modules?

ANSWER

The following steps describe the procedure to re-use inline functions:

  1. Create a new C file for the inline function.
  2. Declare the function type to be static __inline.
  3. Include the C file in the files where you want to use the inline function.

For example:

shiftbits.c

static __inline unsigned long shiftbits(unsigned long x)
{
    return(x<<12)
}

main.c

#include shiftbits.c

void main(void)
{
    unsigned long a;

    a = shiftbits(0xBEC);
}

Article last edited on: 2004-04-24 15:17:10

Rate this article

[Bad]
|
|
[Good]
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