__inline functions for Coldfire V1 / CW 6.3.2

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

__inline functions for Coldfire V1 / CW 6.3.2

429 Views
dougpaulsen
Contributor IV

Greetings: 

 

I am having trouble understanding how the keyword "__inline" works in CW 6.3 and plain ol' C language for Coldfire processors.

 

It seems that functions declared __inline within a file and "called" from elsewhere within that same file are at least compiling okay.  When the function declared in-lined resides in one file and is "called" from multiple other files, the linker is unable to figure it out (I get a Link Error : Undefined "<function name>").

 

Am I doing anything obviously wrong, or is this just the way in-lining works?  I have function prototypes with the the "__inline" keyword, but it looks as though in-lining only works within a single file.

 

Thanks for any suggestions to get around this apparent limitation.

 

....just thinking - free association type thoughts, but perhaps the way around this is to put the __inline declared functions in a single dotH file and then include that dotH file in all files where the in-lined functions are referenced?  That seems reasonable, but I hope I don't have to explain the confusing code to anyone.... 

 

All this effort is, by the way, to eliminate (as near as possible) and function calls from within ISRs.  I'm not aware how CodeWarrior works, but IAR documentation warns that function calls from within interrupts are not only time consuming, but the IAR compiler also cannot guarantee any extra registers used in the called functions will be saved upon ISR entry.  Consequently, all this effort to inline common code rather than make it function calls.  Bother!

Labels (1)
0 Kudos
1 Reply

215 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Doug:

I made some tests reproducing this behavior, and I think you are correct, you can only apply inline optimization from the same source file where the function is declared.

So, it seems you have 2 options (actually both are almost the same):

1) Declare the function you want to inline in every source file that will use it.

2) As you mentioned, you could place this function in a header file and include such header where necessary.

Hope this helps!


Regards!,
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos