为什么函数定义中的函数参数不强制提及`int`数据类型?

Don*_*ild 1 c gcc compiler-warnings

最近我经历了一些类似的代码:(代码是专有的,因此添加了类似的代码)

#include<stdio.h>

void test_it(var)
{
    printf("%d\n",var);
}

int main()
{
    test_it(67);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

test_it没有提到数据类型的参数.

我编译为gcc test_it.c......:令人惊讶的没有警告/错误

我再次编译使用:gcc -Wall test_it.c...:再次没有警告/错误

(现在变得更具侵略性......)

我使用以下方法再次编译它:gcc -Wall -Wextra test_it.c...:
warning: type of ‘var’ defaults to ‘int’最后我得到了警告.

我尝试使用多个参数:

void test_it(var1, var2)
{
    printf("%d\n%d\n",var1, var2);
}

int main()
{
    test_it(67,76);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

同样的行为!!

我也试过这个:

void test_it(var)
{
    printf("%d\n",var);
}

main()   // Notice that no `int` there
{
    test_it(67);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

此代码-Wall仅提供选项警告.

所以我的问题是为什么int数据类型对于函数定义中的函数参数不是必需的?

编辑:

重写问题:

为什么在省略函数参数的数据类型的情况下gcc不给出警告-Wall,但是在省略函数返回类型时给出警告?为什么在第一种情况下忽略它?

Sad*_*que 5

在C89中,假定默认类型为int.这(在C89中有效),但是在C99中已经放弃了默认类型规则.看到不同:

C89 -Compiles fine

C99 prog.c:3:6: error: type of ‘var’ defaults to ‘int’

尝试使用-std=c99标志进行编译.