首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

dev c++ 多文件编译 不能用printf

2012-05-11 
求助:dev c++ 多文件编译 不能用printf我在dev C++里面建了一个C工程,里面包含两个文件:main.c#include s

求助:dev c++ 多文件编译 不能用printf
我在dev C++里面建了一个C工程,里面包含两个文件: 
main.c 
#include <stdio.h> 
#include <stdlib.h> 

int main(int argc, char *argv[]) 


system("PAUSE");
return 0; 


还有一个tes.c 
#include <stdio.h> 
int i; 
i=4; 
printf("###i=%d\r\n",i); 

提示错误: 
编译器: Default compiler 
Building Makefile: "E:\学习\源代码\1\Makefile.win" 
执行 make... 
make.exe -f "E:\学习\源代码\1\Makefile.win" all 
gcc.exe -c tes.c -o tes.o -I"d:/Program Files/DEV-CPP/include" -g 

tes.c:3: warning: data definition has no type or storage class 

tes.c:4: error: syntax error before string constant 
tes.c:4: error: conflicting types for 'printf' 
tes.c:4: note: a parameter list with an ellipsis can't match an empty parameter name list declaration 
tes.c:4: error: conflicting types for 'printf' 
tes.c:4: note: a parameter list with an ellipsis can't match an empty parameter name list declaration 
tes.c:4: warning: data definition has no type or storage class 

make.exe: *** [tes.o] Error 1

[解决办法]
放在函数内
比如

C/C++ code
#include <stdio.h>  void test(){int i;  i=4;  printf("###i=%d\r\n",i); }
[解决办法]
直接一句printf("###i=%d\r\n",i) 是想定义啥?

[解决办法]
C/C++ code
#include <stdio.h>  int i;  i=4;  printf("###i=%d\r\n",i);  //编译器认为你在声明一个函数,这个函数的名字叫printf,还会提示你这个函数的参数是"不允许的类型" 

热点排行