Local static/thread_local variables of inline functions?

后端 未结 1 1669
滥情空心
滥情空心 2021-02-07 13:57

If I have a static local variable or thread_local local variable that is within an inline function that is defined in different translation units, in the final program are they

相关标签:
1条回答
  • 2021-02-07 14:16

    Yes, it's always the same object. By [dcl.fct.spec]/4:

    An inline function with external linkage shall have the same address in all translation units. A static local variable in an extern inline function always refers to the same object. A type defined within the body of an extern inline function is the same type in every translation unit.

    0 讨论(0)
提交回复
热议问题