Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TW#16628] error: implicit declaration of function "clock_gettime" #1302

Closed
Gfast2 opened this issue Nov 22, 2017 · 3 comments
Closed

[TW#16628] error: implicit declaration of function "clock_gettime" #1302

Gfast2 opened this issue Nov 22, 2017 · 3 comments

Comments

@Gfast2
Copy link

Gfast2 commented Nov 22, 2017

Hi ESP-IDF,

Here I am! Right now I'm writing some code that wanna use this POSIX function. But my ESP-IDF compiler won't let my code go through.

I've checked out, in the whole repo of EPS-IDF, component coap is using this function. components/coap/libcoap/src/coap_time.c.
And this function is do mentioned in components/newlib/include/time.h:
int _EXFUN(clock_gettime, (clockid_t clock_id, struct timespec *tp));.
But I just can not let my holy code base pass through. 📟

Here I backed a minimal example:

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"

#include <time.h>
#include <sys/time.h>
#include <unistd.h>

void app_main()
{   
    struct timespec ts;
    clock_gettime(CLOCK_REALTIME, &ts);
    printf("Finished.");
}

Error Log:

CC build/main/hello_world_main.o
/home/gfast2/workspace/clock_gettime/main/./hello_world_main.c: In function 'app_main':
/home/gfast2/workspace/clock_gettime/main/./hello_world_main.c:37:5: error: implicit declaration of function 'clock_gettime' [-Werror=implicit-function-declaration]
     clock_gettime(CLOCK_REALTIME, &ts);
     ^
cc1: some warnings being treated as errors
/home/gfast2/esp/esp-idf/make/component_wrapper.mk:242: recipe for target 'hello_world_main.o' failed
make[1]: *** [hello_world_main.o] Error 1
/home/gfast2/esp/esp-idf/make/project.mk:435: recipe for target 'component-main-build' failed
make: *** [component-main-build] Error 2

@igrr
Copy link
Member

igrr commented Nov 22, 2017 via email

@Gfast2
Copy link
Author

Gfast2 commented Nov 22, 2017

Hi @igrr ,

Thanks for your declearation! I'll give gettimeofday a try.

But Before I close this issue, I'd very pleased to know what is file components/newlib/include/sys/feature.h about? because in this file, _POSIX_TIMERS is mentioned and seems be set to 1

Cheers

Gfast2

@Gfast2
Copy link
Author

Gfast2 commented Nov 22, 2017

If someone like me need time in timespec structure, but have to get the time from ESP32 dure to the situation here mentioned (by gettimeofday). Check out the conversion in between here

@FayeY FayeY changed the title error: implicit declaration of function "clock_gettime" [TW#16628] error: implicit declaration of function "clock_gettime" Nov 24, 2017
@Gfast2 Gfast2 closed this as completed Nov 30, 2017
igrr pushed a commit that referenced this issue Jul 12, 2018
clock_gettime();
clock_settime();
clock_getres();

Closes #1302
catalinio pushed a commit to catalinio/pycom-esp-idf that referenced this issue Jun 28, 2019
clock_gettime();
clock_settime();
clock_getres();

Closes espressif/esp-idf#1302
0xFEEDC0DE64 pushed a commit to 0xFEEDC0DE64/esp-idf that referenced this issue May 5, 2021
with minimal SPIFFS partition size and OTA support for bigger apps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants