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.

How to stop inline functions implemented in header file



I have a header file including a definition of class, which also includes a lot of small member functions. By default it seems the compiler inlines those functions even for debug build, which makes breakpoints grayed out on those functions.  It's also bloating the final code size for release build. Is there any compiler option to stop this default inlining behavior?

  • Function inlining is only performed by the optimizer.  Which ISA and compiler version are you using? (this is not the same as the CCS version)

  • Try explicitly disabling optimization.  In CCS, find the build options for Optimization level, and set the drop-down box to off.  If you are building from the command line, use the option --opt_level=off.

    Thanks and regards,

    -George

  • George Mock said:

    Try explicitly disabling optimization.  In CCS, find the build options for Optimization level, and set the drop-down box to off.  If you are building from the command line, use the option --opt_level=off.

    Thanks and regards,

    -George

    Well, I don't want completely disable optimization, I just want to disable the header file function inlining. Is there any switch for that?

  • Judging from your other posts, you're using a MSP430. I'm not familiar with that processor. Just a guess. The TI compiler manual would suggest "--no_inlining" with optimization level less than 3. Don't know about other compilers. You could move the function body from the class declaration (.h) to an module (.cpp). That should make a function not inline regardless of function size.

  • The post by Mr. Wong is correct.  If those suggestions do not help ... What compiler version are you using?  Please show exactly how the compiler is being invoked for one .c file.

    Thanks and regards,

    -George