The XC16 compiler manual says the following:
The compiler will exclude only built-in functions if they are declared to be static, and if the function definition is preceded by all functions.
At the top of foo.c I declared
static inline void nop_10_times(void);
Then in the definition for ISR it is defined as:
void _CNInterrupt(void) { nop_10_times();
Then, as a test, I put the definition of nop_10_times at the bottom of the file.
static inline void nop_10_times(void) { __builtin_nop(); __builtin_nop(); __builtin_nop(); __builtin_nop(); __builtin_nop(); __builtin_nop(); __builtin_nop(); __builtin_nop(); __builtin_nop(); __builtin_nop(); }
When I compile my project and look at the assembly, it seems that the compiler was really able to completely remove this function in the assembly and leave only the embedded code where it was called in the ISR.
Does anyone know how this worked out? According to the definition in the manual, he said that he would exclude the built-in function if โthe definition of a function precedes all uses of the functionโ.
w1res source share