小编Bow*_*law的帖子

x的冲突类型和先前的声明在这里......什么?

当我有时间的时候,我一直在教自己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)

c function void

8
推荐指数
2
解决办法
5万
查看次数

标签 统计

c ×1

function ×1

void ×1