HC12: Unable to inline from other source files

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

HC12: Unable to inline from other source files

跳至解决方案
2,434 次查看
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

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,165 次查看
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 项奖励
回复
2 回复数
1,165 次查看
falken
Contributor I
Ok, thanks.
0 项奖励
回复
1,166 次查看
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 项奖励
回复