HC12: Unable to inline from other source files

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HC12: Unable to inline from other source files

Jump to solution
1,863 Views
falken
Contributor I
I noticed today that when calling

// foo.c
#pragma INLINE
void foo(void){xxx}

from

// bar.c
void bar(void)
{
foo();
}

it's not inlined.
When calling INLINE functions from the same source file, it works.

Am I doing something wrong or is it not implemented?

HCS12 with CW 3.1 & 4.5 with build option -Oi

/Thanks

Message Edited by CrasyCat on 2007-04-13 02:27 PM

Labels (1)
Tags (1)
0 Kudos
1 Solution
594 Views
CrasyCat
Specialist III
Hello
 
This is fully normal behavior.
 
When compiling the compiler has only visibility on the current compilation unit (the source file and all the files it includes).
If a function is implemented in another module, the compiler will not be able to inline it as it will not know which is the code from the function.
 
If you wish to inline a function in several different source files, I would recommend you to implement a static function in a header file and include the header file in different source file.
 
CrasyCat

View solution in original post

0 Kudos
2 Replies
594 Views
falken
Contributor I
Ok, thanks.
0 Kudos
595 Views
CrasyCat
Specialist III
Hello
 
This is fully normal behavior.
 
When compiling the compiler has only visibility on the current compilation unit (the source file and all the files it includes).
If a function is implemented in another module, the compiler will not be able to inline it as it will not know which is the code from the function.
 
If you wish to inline a function in several different source files, I would recommend you to implement a static function in a header file and include the header file in different source file.
 
CrasyCat
0 Kudos