atmel - Issues in C with including time.h? -
i have file in massive project i'm working on called timekeeper.h (and .c)
--------------edit---------------fixed bool thing still broken though--------------
#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 when attempt build project, there bunch of errors in file (and file using time.h). here's of errors in timekeeper.h:
expected ')' before 'time' line 6 expected '"', ',', ';','asm', or '__attribute__' before 'getcurrenttime' line 10 i suspect timekeeper doesn't know time_t is, though has
#include <time.h> i getting errors like
implicit declaration of function 'localtime' in timekeeper.c file. , yes, timekeeper.c #includes timekeeper.h
any appreciated.
----additional information----- i'm using atmel studio 6.0 here 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...... ----edit 2------
i added #include <stdbool.h> , changed bool bool in line 6 errors still there.
there no type bool in c. there type bool, it's visible if have #include <stdbool.h>.
when add #include <stdbool.h> , change bool bool, code compiles without error. (i had delete line numbers.)
i'd suggest picking name other time parameter isafter , other functions. time name of function declared in <time.h>. don't think causes conflict in case, unique names avoid confusion.
because bool unrecognized type name, compiler reports syntax error on
bool isafter(time_t time); any errors see after spurious. if syntax errors, start fixing error on earliest reported line , recompiling.
edit:
based on further comments, adding #include <stdbool.h> , changing bool bool doesn't appear have helped. , particular message you're getting seem imply time_t not recognized -- should not happening.
try simple 2-line source file (and make sure file name has .c suffix):
#include <time.h> time_t foo; if fails, explanation can think of compiler and/or runtime library installation corrupted somehow.
do have option view preprocessed source? if so, applying above 2-line source should show preprocessed contents of <time.h>, should include definition time_t.
Comments
Post a Comment