Declaration or Definition in C

后端 未结 5 1153
借酒劲吻你
借酒劲吻你 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:27

    The C standard says that

    A definition of an identifier is a declaration for that identifier that: for an object, causes storage to be reserved for that object (…)

    Definitions encompass declarations, i.e., every definition is necessarily a declaration, so it doesn’t make sense to say that

    int i;
    

    is not a declaration. It is a declaration which also happens to be a definition. Or, it is a definition, hence a declaration.

提交回复
热议问题