Error with <time.h>

Go To Last Post
2 posts / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everyone!

I'm working with SAMR35, ASF, Atmel Studio 7.

In the project I'm trying to use the <time.h> library, but it keeps showing the same error:


Severity    Code    Description
Error        implicit declaration of function 'settimeofday' [-Werror=implicit-function-declaration]


In the code I need to use the functions "settimeofday()", "gettimeofday()" and "time()", also the struct "timeval".

No matter where I put the "#include <time.h>" it keeps sending this error.


This is the part of the code where the time is set :

unionT time_u;
time_u.time_array[3] = data[0];
time_u.time_array[2] = data[1];
time_u.time_array[1] = data[2];
time_u.time_array[0] = data[3];
printf("GPE - New Value from Payload : %d", time_u.time_int);
struct timeval tv;
tv.tv_sec = time_u.time_int;
tv.tv_usec = 0;
settimeofday(&tv, NULL);
time_t tN = time(NULL);
printf("GPE - New timestamp : %d\r\n", tN);


  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


I have found that the include needed for "gettimeofday()" is "#include <sys/time.h>" and it includes the base "time.h" aswell.

Now the error is the following:

Severity    Code    Description    Project    File    Line
Error        ld returned 1 exit status    APPS_ED_DEMO_SER_NWK_PROVISION1    collect2.exe    0

I think I saw a post about this somewhere in this forum. EDIT: this was in AVR forum, and for what I read, it doesn't apply

Last Edited: Mon. Mar 9, 2020 - 05:19 PM