What is C local function declaration mechanism?

前端 未结 3 1207
终归单人心
终归单人心 2021-01-21 09:07

Local function declaration seems to be permitted in gcc, and I found a discussion on this: Is there any use for local function declarations?

However, my question is: is

3条回答
  •  死守一世寂寞
    2021-01-21 09:31

    Local extern declarations indeed work just like ones outside the function except with limited scope, or alternately just like local static declarations except that the entity is externally accessible by linkage.

    Why? Well, why not? It's just an extrapolation of the general rules for declarations and the extern specifier into a specific context.

    I can't recall ever (purposely) using a local extern function declaration, but a few times I've hacked in a debugging variable using a local extern variable declaration. The extern declaration can be placed in some highly nested code and pass data to a debug printer in another TU.

提交回复
热议问题