MPC560xB inline function utilization

cancel
Showing results for 
Search instead for 
Did you mean: 

MPC560xB inline function utilization

224 Views
romainbenet
Contributor III

Hey,

 

in my project I use for each element a header file (input / output data interface) and an associated source file (data interface utilization)

So per example a function which returns content of the STM timer:

 

in the header file: extern UINT32 u32GetTime(void); // UINT32 = unsigned long int

in the source file: UINT32 u32GetTime(void) { return (STM.CNT.R); }

 

And I want to write this simple function as inline to save time

 

When I write this function in my header file as: inline UINT32 TIMS_u32GetFreeRunningTimerInUs(void) { return (STM.CNT.R); }

the content of the function is copying where it is used (and not called as another function, so inline utilization)

But when I want to write this function as inline in the source file with the external declaration in the header the linker don't copy the associated code and keep the call function.

 

Is there an option in the linker to use inline function as (correct this example if necessary) :

 

in header file: extern UINT32 u32GetTime(void);

in source file : inline UINT32 u32GetTime(void) { return (STM.CNT.R); }

 

Thank you for your help

 

Romain

Labels (1)
Tags (1)
0 Kudos
1 Reply

134 Views
martin_kovar
NXP Employee
NXP Employee

Hi Romain,

I tried few configurations, but only one of them works correct. Please look at the following URL. This is what I have tried and it worked.

c - How to declare an inline function in C99 multi-file project? - Stack Overflow 

Regards,

Martin

0 Kudos