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
  • Hello Krumita,

    Thank you for contacting DevZone at NordicSemi.

    I am not sure if we are on the same page or not, but here is what I did:

    I started with hello-world sample for the nrf52840dk in the ncs v2.4.0.

    I simply added:

    #include <time.h>
    #include <math.h>
    

    and then I was able to use the functions defined within those headers.

    To print the floating point numbers, I had to add following in the prj.config:

    CONFIG_SFLOAT=y
    CONFIG_CBPRINTF_FP_SUPPORT=y

    I can also see there are other Kconfig options available related to the DSP and Floating points

    (for example: CONFIG_FPU to enable and use the floating point unit)

    Below you can see the code I have used and the output on 52840dk

    BR,

    Naeem

Reply
  • Hello Krumita,

    Thank you for contacting DevZone at NordicSemi.

    I am not sure if we are on the same page or not, but here is what I did:

    I started with hello-world sample for the nrf52840dk in the ncs v2.4.0.

    I simply added:

    #include <time.h>
    #include <math.h>
    

    and then I was able to use the functions defined within those headers.

    To print the floating point numbers, I had to add following in the prj.config:

    CONFIG_SFLOAT=y
    CONFIG_CBPRINTF_FP_SUPPORT=y

    I can also see there are other Kconfig options available related to the DSP and Floating points

    (for example: CONFIG_FPU to enable and use the floating point unit)

    Below you can see the code I have used and the output on 52840dk

    BR,

    Naeem

Children
No Data
Related