How to use time.h and math.h in nrf connect sdk?

1)I want to use "mktime" and "localtime" in my nrf52840 code ,how do i include time.h file?


2)I am using math.h file , in prj.conf i define "CONFIG_NEWLIB_LIBC=y"  but I continuously  get error as below ,how do i resolve it?

error:

/usr/include/math.h:415:33: error: '_Float128' is not supported on this target
415 | # define _Mdouble_ _Float128
Parents
  • No, you are going wrong

    /usr/include  its a system library, basic files which are used.


    1) In sdk v2.3.0 file as below 
    /ncs/v2.3.0/modules/lib/hostap/src/utils/os_zephyr.c

    In function

    int os_mktime(int year, int month, int day, int hour, int min, int sec,
    os_time_t *t)

    using 
    mktime and localtime  using this function where i can find its definition.

    can you give me exact path?


    2)In file as below
    ncs/v2.3.0/nrf/include/net/nrf_cloud_alerts.h

    included math.h
    file

    from where it is called( from which path).?


    3) in first example you give me sample code with gmtime , i want with mktime ,can you give me with it.
  • Hello Kumrita,

    I am still not very sure that I understood you 100%, but here is what I have now.

    Previously, I did not pay attention to the newlib_libc config.

    So now, after having proper configs, I can use the mktime and localtime.

    The catch is that we need to compile project first with these configs so that old files are not pulled and we could use the functions from the newlib. 

    Before compilation: can not use mktime

    After compilation: can use mktime and localtime

    Showing successful compilation with time.h and math.h

    BR, Naeem

Reply
  • Hello Kumrita,

    I am still not very sure that I understood you 100%, but here is what I have now.

    Previously, I did not pay attention to the newlib_libc config.

    So now, after having proper configs, I can use the mktime and localtime.

    The catch is that we need to compile project first with these configs so that old files are not pulled and we could use the functions from the newlib. 

    Before compilation: can not use mktime

    After compilation: can use mktime and localtime

    Showing successful compilation with time.h and math.h

    BR, Naeem

Children
Related