【发布时间】:2013-08-15 18:08:20
【问题描述】:
我正在处理的这个大型项目中有一个名为 timeKeeper.h(和 .c)的文件
-------------编辑---------------修复了 BOOL 东西仍然坏掉了---------- ----
#ifndef TIMEKEEPER_H_
#define TIMEKEEPER_H_
#include <time.h>
#include <stdbool.h>
bool isAfter(time_t time);
void setTime(char seconds, char minutes, char hours, char day,
char month, char year);
void tickSeconds(void);
time_t getCurrentTime(void);
time_t createTime(char seconds, char minutes, char hours, char day,
char month, char year);
void startTime(void);
time_t addSeconds(int seconds, time_t time);
long timeRemaining(time_t time);
void rtc_set(char seconds, char minutes, char hours, char days, char months,
char year);
#endif
当我尝试构建我的项目时,此文件(以及任何使用 time.h 的文件)中有一堆错误。以下是 timeKeeper.h 中的一些错误:
expected ')' before 'time' Line 6
expected '"', ',', ';','asm', or '__attribute__' before 'getCurrentTime' Line 10
我怀疑 timeKeeper 不知道 time_t 是什么,即使它有
#include <time.h>
我也遇到类似的错误
implicit declaration of function 'localtime'
在我的 timeKeeper.c 文件中。是的,timeKeeper.c #includes timeKeeper.h
非常感谢任何帮助。
----附加信息----- 我正在使用 Atmel Studio 6.0 这是timeKeeper.c
#include "FreeRTOS.h"
#include "task.h"
#include "print_funcs.h"
#include "timeKeeper.h"
#include "telemetryLookup.h"
void timeTask(void* pvParameters);
time_t TIME;
blah blah blah......
----编辑2-----
我在第 6 行添加了#include <stdbool.h> 并将Bool 更改为bool,但错误仍然存在。
【问题讨论】:
-
这可能取决于包含
tineKeeper.h之前包含的包含。在您的平台上使用最少的测试程序是否也会出现这些错误?顺便说一句:你的平台是什么? -
您可能会显示
timeKeeper.cup 的开头,直到包括timeKeeper.h。 -
发布代码时,每行添加行号无济于事;我喜欢能够复制和粘贴代码并自己编译。如果您需要引用错误消息中的行号,请在该行添加
/* line 6 */之类的注释。 -
好的,Keith,从现在开始我会这样做。
-
正如 Keith 所说,将
Bool更改为bool