Why does omitting explicit 'int' type for a parameter fail to compile in gcc sometimes?

前端 未结 2 1753
予麋鹿
予麋鹿 2020-12-21 06:48

When declaring variables in C you can omit the type sometimes if you want to declare an int.

Why does omitting explicit \'int\' type for a parameter fai

2条回答
  •  心在旅途
    2020-12-21 07:24

    The compiler is employing one of two grammars.

    When applying the K&R grammar, undeclared parameters are allowed, and default to ints.

    When applying the non-K&R grammar, all parameters must comply with the parameter declaration syntax i.e. declared with types and names.

    You invoke one or the other by choosing the corresponding declaration style.

提交回复
热议问题