奇怪的
和
冲突的
行为
测试1
#include <stdio.h>
#include <limits.h>
void main(){
char c='\0';
float f=0.0;
xof(c,f);/* at this point implicit function declaration is
generated as int xof(int ,double ); */
}
int xof(char c,float f)
{
printf("%d %f\n", c,f);
}
隐式函数声明将是int-xof(int,double);
错误为
变量名称。c: 8:5:错误:“xof”int xof(char)的类型冲突
c、 浮子f)
我理解这一点,因为
测试2
#include <stdio.h>
#include <limits.h>
void main(){
unsigned int a =UINT_MAX;
int b=0;
xof(a); /* implicit function declaration should be int xof(int); */
}
int xof(unsigned a,int b)
{
printf("%d %d\n", a,b);
}
隐式函数声明为int-xof(int);
这应该与函数定义冲突
输出为
具有
“a”
“b”
具有“未定义垃圾”
-1 12260176
有人能解释一下吗。
提前谢谢。