Hello, I'm using CW 6.2 on a HS08QE16.
I've a function in foo.c:
#pragma INLINE
void bar(void)
{
//do something short
}
Compiler has the -Oi flag.
Now, if' I call this function within foo.c, it's inlined.
But if I use it on another file (for example main.c) it's not inlined. And I wish that it will be inlined everywhere.
In foo.h there is simply the declaration:
void bar(void);
I tried using extern:
extern void bar(void);
but it doesn't change anything.
Some ideas?
Thanks Bye Jack
Solved! Go to Solution.
Hello,
the compiler will only inline functions he is able to 'see': if the function is inside the same file, and above where you want to inline it.
So it is a good idea to place the functions to be inlined at the beginning of the C file.
If your function 'bar' does something short, you may consider to make a C macro out of it and have it placed in a header file: that way you can get inlining through the preprocessor.
The other idea would be to have bar() in a separate small file (defined as static function, btw):
Then you could include this file in each of the modules where you want to inline it.
In order not to change a lot of files (to include this 'inline' file), you could simply use the -AddIncl command line switch (e.g. -AddInclMyIncludeFile.inc )
BK
Hello,
the compiler will only inline functions he is able to 'see': if the function is inside the same file, and above where you want to inline it.
So it is a good idea to place the functions to be inlined at the beginning of the C file.
If your function 'bar' does something short, you may consider to make a C macro out of it and have it placed in a header file: that way you can get inlining through the preprocessor.
The other idea would be to have bar() in a separate small file (defined as static function, btw):
Then you could include this file in each of the modules where you want to inline it.
In order not to change a lot of files (to include this 'inline' file), you could simply use the -AddIncl command line switch (e.g. -AddInclMyIncludeFile.inc )
BK