Skip to main content
Graduate
July 1, 2025
Solved

Using time.h asserts

  • July 1, 2025
  • 3 replies
  • 470 views

Hello,
I am currently trying to convert my STM32CubeIDE (based on makefile) project to a STM32 VScode extension project based on CMake.

Everything seemed to work smoothly until I was met with an issue calling the 'localtime' function from the standard 'time.h' class.

This function has worked well so far in my CubeIDE project and I am using this to convert a uint32_t epoch to a tm struct.
In my CMake project this fails by calling '_exit' and getting stuck there.
The callstack is as follows:

SharonVEC_0-1751357896942.png

I am not sure what is the issue, is the standard library not implemented in the newlib of the CLT package?
I tried looking at the 'gcc-arm-none-eabi.cmake' script and compare it to the makefile but none of the changes I tried making made any difference.
Thanks.

    This topic has been closed for replies.
    Best answer by Pavel A.

    Try to use localtime_r instead of localtime()

     

    3 replies

    Pavel A.Answer
    Super User
    July 1, 2025

    Try to use localtime_r instead of localtime()

     

    SharonVECAuthor
    Graduate
    July 1, 2025

    You are correct! this solved my issue.

    Can you please share how was I supposed to know this? is _REENT_ONLY defined somewhere maybe?

    Super User
    July 1, 2025

    Hmm I just guessed that the variant without dependency on the reent struct can work. No idea why the reent struct is not allocated, given that VS Code uses the same newlib as the previous toolchain.