AnsweredAssumed Answered

MPC560xB inline function utilization

Question asked by Romain BENET on Sep 21, 2016
Latest reply on Sep 22, 2016 by Martin Kovar



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