This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F2800157: Compilation of inline functions

Part Number: TMS320F2800157

Hi Team,

The GetBoardWorkingFlag() function is defined as follows, which is an inline type.

Then call this function somewhere.

Because it is an inline function, this function should not exist after compilation, and will be expanded where it is called (similar to the effect of a macro definition).

And there is indeed no such function in the map file.

But where this function is called, the assembly instruction is LCR (function jump instruction).

static inline bool GetBoardWorkingFlag()
{
    return (boardStatus_WorkingNormal == boardStatus);
}

bool boardWorkingFlag = GetBoardWorkingFlag();

0094b3: 7640919E LCR GetBoardWorkingFlag   ---GetBoardWorkingFlag() is of inline type and should be expanded where it is called, without being called. Why is there still a function jump instruction here?

0094b5: 9645 MOV *-SP[5], AL

--

Thanks & Regards

  • Hello Yale,

    I was able to replicate this on my side, and my understanding is the same as yours, I believe using static inline functions shouldn't create a separate function call. I don't know the exact reasoning behind this, but for what you're trying to accomplish it might be better to use a macro function like below:

    #define GetBoardWorkingFlag(a, b)   (a == b)
    
    void main(void)
    {
        <other code here>
        
        boardWorkingFlag = GetBoardWorkingFlag(boardStatus_WorkingNormal, boardStatus);
        
        <other code here>
    }

  • Hi Omer,

    Thanks for your reply.

    This issue has been resolved by choose this option:

    --

    Thanks & Regards