“extern” inside a function?

后端 未结 3 1234
半阙折子戏
半阙折子戏 2020-12-31 00:51

Well, reading \"a bit old\" book (\"The C programming language\", second edition, by Dennis Ritchie), I came a cross the following:

An external variab

3条回答
  •  -上瘾入骨i
    2020-12-31 00:59

    The extern is linkage. It means this name, max, is linked to other occurrences of the name, possibly in other files. (That is, when the object modules are linked together to make an executable, all the linked references to this name will be made to refer to the same object.)

    The scope of this declaration is the remainder of the function body it is in. That means other functions in this file do not see the name declared by this declaration (unless they declare it themselves).

    Scope and linkage are different things.

提交回复
热议问题