本文介绍了该计划标准是否符合要求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 以下程序标准是否符合? (尽可能减少,因此仍然显示问题) / * begin * / #include< stdio.h> void xfprintf(FILE *); void xfprintf(FILE * f){ fprintf(f," x \ n"); } int main(void) { xfprintf(stderr); 返回0; } / * end * / 它在没有警告的情况下使用gcc进行编译并且工作正常,但是尝试使用特定的其他流行的编译器来编译它,它会在诊断后生成 : lc -ansic -A -shadows -unused -O -c xfprintf.c -o xfprintf.obj 错误xfprintf.c:4重新定义'' xfprintf'' 错误c:\ lcc\include\stdio.h:116此前''xfprintf''的先前定义 2错误,0警告 1错误 make:*** [xfprintf.obj]错误1 谁在这里,我的程序或编译器有问题? 解决方案 int foo(void); int foo(void){return 42; }是a定义。 显然,xfprintf()定义了两次。 你的代码片段是有效的ISO C. 请不要''喂匿名巨魔。 - Richard - :wq 就别喂匿名巨魔。 为什么你认为Fumeur是一个巨魔? - [mail ]:Chuck F(cinefalconer at maineline dot net) [page]:< http://cbfalconer.home.att.net> 尝试下载部分。 - 通过 http://www.teranews.com Is the following program standard conform?(reduced as much as possible so it still shows the problem) /* begin */#include <stdio.h> void xfprintf(FILE *); void xfprintf(FILE *f) {fprintf(f, "x\n");} int main(void) {xfprintf(stderr);return 0;}/* end */It compiles with gcc without warnings and works correctly, but tryingto compile it with a particular other popular compiler, it yields thefollowing diagnostics: lc -ansic -A -shadows -unused -O -c xfprintf.c -o xfprintf.objError xfprintf.c: 4 redefinition of ''xfprintf''Error c:\lcc\include\stdio.h: 116 Previous definition of ''xfprintf'' here2 errors, 0 warnings1 errormake: *** [xfprintf.obj] Error 1 Who is at fault here, my program or the compiler? 解决方案 int foo(void); is a declaration while int foo(void) { return 42; } isa definition.Apparently, xfprintf() is defined twice.Your snippet is valid ISO C.Please don''t feed the anonymous troll. -- Richard--:wq Please don''t feed the anonymous troll.Why do you consider Fumeur to be a troll? --[mail]: Chuck F (cbfalconer at maineline dot net)[page]: <http://cbfalconer.home.att.net>Try the download section. --Posted via a free Usenet account from http://www.teranews.com 这篇关于该计划标准是否符合要求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-23 13:50