当我有时间的时候,我一直在教自己C几个月,我遇到了一个问题我不知道如何解决.
具体来说,当我尝试使用gcc编译它时,我得到:
geometry.c:8: error: conflicting types for ‘trapezoid’ geometry.c:7: note: previous declaration of ‘trapezoid’ was here geometry.c:48: error: conflicting types for ‘trapezoid’ geometry.c:7: note: previous declaration of ‘trapezoid’ was here geometry.c:119: error: conflicting types for ‘trapezoid_area’ geometry.c:59: note: previous implicit declaration of ‘trapezoid_area’ was here geometry.c: In function ‘cone_volume’: geometry.c:128: error: called object ‘3.14100000000000001421085471520200371742248535156e+0’ is not a function geometry.c: In function ‘cylinder_volume’: geometry.c:136: error: called object ‘3.14100000000000001421085471520200371742248535156e+0’ is not a function
现在,我想我可能需要对这些功能进行类型转换,但同样,我不确定.
看起来它想要读取我定义为3.141的PI作为函数.有没有办法可以避免使用魔法数字3.141(虽然它比其他数字少得多)?
//Geometric formulae
#include <stdio.h>
#include <math.h>
#define …
Run Code Online (Sandbox Code Playgroud)