Tag: 隐式

C一个函数的明确声明

我在Linux和gcc 4.2.3上。 对于下面的代码部分,隐式调用lp_parm_talloc_string函数,然后定义它: char *lp_parm_string(const char *servicename, const char *type, const char *option) { return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL); } /* Return parametric option from a given service. Type is a part of option before ‘:’ */ /* Parametric option has following syntax: ‘Type: option = value’ */ /* the returned value is talloced in […]

即使添加了#include ,也会隐式声明popen

这是我的代码的一小部分。 #include #include #include #include #include #include #include #include #include #include #include #include … FILE * pipe; … pipe = popen (“ls /tmp -1”, “r”); … pclose(pipe); blarg.c:106: warning: implicit declaration of function ‘popen’ blarg.c:106: warning: assignment makes pointer from integer without a cast blarg.c:112: warning: implicit declaration of function ‘pclose’ blarg.c:118: warning: assignment makes […]

具有旧样式函数的C编译器的行为,没有原型

当我的程序包含两个文件时: main.c中 #include int main(void) { printf(“%lf\n”,f()); return 0; } func.c double f(int a) { return 1; } 编译器不显示任何错误。 当我的程序只包含一个文件时: main.c中 #include int main(void) { printf(“%lf\n”,f()); return 0; } double f(int a) { return 1; } Visual C ++ 2008编译器显示以下错误: Error 2 error C2371: ‘f’ : redefinition; different basic types d:\temp\projects\function1\function1\1.c 8 function1 任何人都能解释这种奇怪的行为吗?