【发布时间】:2013-02-25 02:37:16
【问题描述】:
在我的原型文件 proto.h 中,我有
#define LOOP_LIMIT 90.00
#define PI 3.14159
#ifndef _PROTO_H
#define _PROTO_H
#include <stdio.h>
#include <math.h>
#include "get_problem.c"
#include "deg_to_rad.c"
#include "evaluate_sin.c"
#include "evaluate_cos.c"
#include "evaluate_tan.c"
int main(void);
int get_problem();
double deg_to_rad(int deg);
void evaluate_sin(int deg);
void evaluate_cos(int deg);
void evaluate_tan(int deg);
#endif
在我的 lab7.c 中,我有我的主要功能,我包含了 proto.h。当我尝试使用“make”命令在 Linux 上编译时,我收到以下消息:
gcc -c deg_to_rad.c deg_to_rad.c:在函数“deg_to_rad”中:
deg_to_rad.c:2: 错误:“PI”未声明(在此函数中首次使用)
deg_to_rad.c:2: 错误:(每个未声明的标识符只报告一次
deg_to_rad.c:2:错误:对于它出现的每个函数。)
make: * [deg_to_rad.o] 错误 1
我真的不明白这一点,因为我的主函数正确使用了 LOOP_LIMIT,但 PI 不起作用。
deg_to_rad.c:
double deg_to_rad(int deg) {
double rad = (PI * deg) / 180;
return rad;
}
【问题讨论】:
-
如果您显示有问题的代码会有所帮助。
-
在
.h文件中包含.c文件至少很奇怪。