大佬教程收集整理的这篇文章主要介绍了如何使用旧语法和现代编译器编译C代码?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
http://tog.acm.org/resources/GraphicsGems/
某些void或int函数是在没有返回类型的情况下定义的,这会生成警告.
ConcaveScan.c:149:1: warning: type specifier missing,defaults to 'int' [-Wimplicit-int] compare_ind(u,v) int *u,*v; {return pt[*u].y <= pt[*v].y ? -1 : 1;}
cc -g -Wno-implicit-int -Wreturn-type -c -o AAPolyScan.o AAPolyScan.c AAPolyScan.c:106:4: error: non-void function 'drawPolygon' should return a value [-Wreturn-type] return; /* (null polygon) */
据我了解,似乎编译器认为它被隐含地声明为返回int的函数,但该函数返回void,导致错误.在C中从声明返回int的函数返回是否有意义?我在这里很困惑..
怎么可以很好地编译呢?我不一定无法编译,但警告不是很有用.它是用旧语法编写的,我知道.
-Wno-implicit-int
另外,你确定你正在使用llvm-gcc吗?当我用你的例子进行测试时,我不得不添加-Wall来让gcc说:
$gcc -Wall -c -o example.o example.c example.c:8: warning: return type defaults to ‘int’
但克朗说:
$clang -c -o example.o example.c example.c:8:1: warning: type specifier missing,defaults to 'int' [-Wimplicit-int] compare_ind(u,*v; {return pt[*u].y <= pt[*v].y ? -1 : 1;} ^~~~~~~~~~~ 1 warning generated.
没有任何标志,并且该消息更符合您问题中的警告.在我的机器上:
$gcc --version i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) Copyright (C) 2007 Free Software Foundation,Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITnesS FOR A PARTICULAR PURPOSE. $cc --version Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) Target: x86_64-apple-darwin12.4.0 Thread model: posix
以上是大佬教程为你收集整理的如何使用旧语法和现代编译器编译C代码?全部内容,希望文章能够帮你解决如何使用旧语法和现代编译器编译C代码?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。