2025-07-01 2:13 AM
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:
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.
Solved! Go to Solution.
2025-07-01 2:52 AM
2025-07-01 2:52 AM
Try to use localtime_r instead of localtime()
2025-07-01 3:57 AM
You are correct! this solved my issue.
Can you please share how was I supposed to know this? is _REENT_ONLY defined somewhere maybe?
2025-07-01 11:09 AM
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.