How will i know whether inline function is actually replaced at the place where it is called or not?

前端 未结 10 788
长发绾君心
长发绾君心 2020-11-27 16:17

I know that inline function are either replaced where it is called or behave as a normal function.

But how will I know whether inline function is actually replaced a

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 17:20

    The decision to inline or not a function is made by compiler. And since it is made by compiler, so YES, it can be made at compile time only.

    So, if you can see the assembly code by using -S option (with gcc -S produces assembly code), you can see whether your function has been inlined or not.

提交回复
热议问题