Declaration or Definition in C

后端 未结 5 1149
借酒劲吻你
借酒劲吻你 2020-12-05 04:50

From External Variables Wiki:

If neither the extern keyword nor an initialization value are present, the statement can be either a declaration o

5条回答
  •  鱼传尺愫
    2020-12-05 05:23

    As C uses the terms:

    A "definition" creates something (which occupies some sort of memory). It also describes something. This means a "definition" is also a "declaration".

    A "declaration" just describes something. The idea is that the compiler needs to know how to build the code that uses the thing defined elsewhere. Later, the linker then links the use to the something.

    Declarations allow you to compile code and link it (later) as a separate step.

提交回复
热议问题