Is it possible to force a function not to be inlined?

前端 未结 9 620
攒了一身酷
攒了一身酷 2020-12-01 11:30

I want to force a little function not to be compiled as inline function even if it\'s very simple. I think this is useful for debug purpose. Is there any keyword to do this?

9条回答
  •  庸人自扰
    2020-12-01 12:28

    Is it possible to force a function not to be inlined?

    I won't even attempt to answer that question, because it's irrelevant to be concerned with this except for the two reasons outlined below.

    Inlining basically is

    1. an optimization that's mostly transparent to you
    2. a way to allow functions to be defined in headers without getting multpile definition errors

    (Some would switch the order of these two, but I stick to the traditional order.)

    Unless either A) you absolutely need to define a function in some header or B) you are profiling and optimizing a piece of code and know better than the compiler what should be inlined and what shouldn't, inlining should be of no concern to you.
    It certainly shouldn't be a concern because of debugging. Your debugger should (and in the case of VC also does) take care of that for you.

提交回复
热议问题