Hello,
I'm trying to inline this Little function but the Compiler (S12ZCPU) refuses to do that. Is there any Limitation I violated?
__inline__ void FunctionToInline(uint16 *current_ptr)
{
current_ptr[0] -= Adc0Offset;
current_ptr[1] -= Adc1Offset;
}
With another function that staturates a value, inlining worked well.
Thanks for your help
Solved! Go to Solution.
Hello Markus,
I tried to include similar code into one of my projects.
I found that I had to enable both "optimize for speed" and "Bottom-Up Inlining", in order for this function to be inlined. I left "inline level" at the default ("smart").
Hope that helps.
MJW
Hello Markus,
Are you getting the compilation error? If yes, what is the error?
Which version of CodeWarrior you are using?
I am able to compile this function.
Even, if I disassemble the file, I can see the difference with the use of "__inline__" and without it.
I have checked on CW10.6
-Arpita
Hi,
thanks for your answer.
I get no compilation error but a warning, that the function cannot be inlined.
I'm using CW 10.5
In my compilation output I see no difference if inline is used or not
Hello,
See below the basic code which I have developed:
********************************************************************
int a[2], Adc0Offset, Adc1Offset;
__inline__ void FunctionToInline(int *current_ptr)
{
current_ptr[0] -= Adc0Offset;
current_ptr[1] -= Adc1Offset;
}
void main(void)
{
Adc1Offset=10;
Adc0Offset=8;
EnableInterrupts;
/* include your code here */
FunctionToInline(a);
for(;;) {
__RESET_WATCHDOG(); /* feeds the dog */
} /* loop forever */
}
*********************************************************************
Right click on the file and select Disassemble option.
With inline, I can see that the function has not allocated a memory space and main() starts at 0x00, while if I remove "__inline__", main() starts at 0000001F, and function is treated as a subroutine.
I am not sure why it is not working in your code? Are you using code optimization?
Can you share your code so that issue can be replicated at our end and then we can find the cause.
-Arpita
Thanks for your answer.
The original code where the inline function is called looks like this:
The inline function itself is defined in the module header:
Project Compiler Settings:
I've already tried various compiler settings (especially inline and optimization level).
Regards
Markus
Hello Markus,
I tried to include similar code into one of my projects.
I found that I had to enable both "optimize for speed" and "Bottom-Up Inlining", in order for this function to be inlined. I left "inline level" at the default ("smart").
Hope that helps.
MJW
Hi,
thanks for your answer. I tried your suggested Settings but with my Project it make no difference. I still got the warning that the function cannot be inlined.
I've also tried to setup a new project, but that didn't change anything.