分页: 1 / 1
为什么说sin未定义?
发表于 : 2006-08-29 9:56
由 VisionMiracle
用的Anjuta
明明在函数库设定里把C标准库选上了阿
发表于 : 2006-08-29 10:26
由 fteye
应该选上cmath库吧
#include<cmath>
发表于 : 2006-08-29 11:16
由 ectotherm
如果包含 cmath,sin 在 std 中,如果是 math.h 就没有名称空间了。用哪个取决于于你是写 c 还是 c++。
发表于 : 2006-08-29 11:31
由 VisionMiracle
ComputeCoef.c:2:17: error: cmath: No such file or directory
ComputeCoef.c: 在函数 ‘main’ 中:
ComputeCoef.c:33: 警告: 隐式声明与内建函数 ‘sin’ 不兼容
发表于 : 2006-08-29 11:35
由 ectotherm
晚上回去看看,我这里只有 mingw,ps 把你的整个代码贴上来看看。
发表于 : 2006-08-29 12:05
由 fteye
#include<math.h>
发表于 : 2006-08-29 12:10
由 VisionMiracle
#include <stdio.h>
#include <cmath>
#define Resolution 512
#define R Resolution
#define TubeNum 512
#define TN TubeNum
#define ProjNum 256
#define PN ProjNum
#define PixelSize 1
#define PS PixelSize
#define RelativeTubeSpace 1 /* Compared to PixelSize */
#define RTS RelativeTubeSpace
#define AbsoluteTubeSpace PS*RTS
#define ATS AbsoluteTubeSpace
#define ImageWidth PS*R
#define IW ImageWidth
#define pi 3.1415926
main ()
{
int i1;
for (i1=1;i1<=PN;i1++)
{
double theta=(pi/PN)*(i1-1);
int i2;
for (i2=1;i2<=TN;i2++)
{
double t=(i2-(1+TN)/2)*RTS;
double j2;
if (theta==0)
j2=sin(t)+R/2+1;
printf("\n");
}
}
}
发表于 : 2006-08-29 12:41
由 ectotherm
我用 mingw 3.4.2 编译什么问题都没有啊,ps 你那个代码是谁写的,糟糕得一塌糊涂。
发表于 : 2006-08-29 12:55
由 fteye
也许是anjuta的链接库设置的问题
发表于 : 2006-08-31 8:53
由 VisionMiracle
ectotherm 写了:我用 mingw 3.4.2 编译什么问题都没有啊,ps 你那个代码是谁写的,糟糕得一塌糊涂。
不好意思,我写的,编程很烂,C更是好久没用,糟糕之处还请指正
发表于 : 2006-08-31 9:03
由 ectotherm
简单地说 C++ 不是 C,避免使用 #define,还有声明 main() 实际上是 int main() 不写会默认成 int,但是这个在 C99 还是 C89 中已经被淘汰了。
先指出两点,其它的要更详细的了。
发表于 : 2006-09-01 12:16
由 lysting
哈哈~~~我想,是php把缩格给过滤掉了,所以才这么乱,我也用php写过论坛,也曾经干过这样的坏事

不过楼主还要区分有.h和无.h的区别,namespace ,for循环里的 ++, 还有代码风格......
发表于 : 2006-09-01 13:10
由 ectotherm
...缩进对上面的代码是小得不能再小的问题,那个问题用 astyle 格式化下就解决了。
发表于 : 2008-06-26 11:10
由 jiazufei
数学标准库在 /usr/lib/libm.a里,所以这样编译
gcc -Wall *.c /usr/lib/libm.a -o *