cancel
Showing results for 
Search instead for 
Did you mean: 

Using time.h asserts

SharonVEC
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Super User

Try to use localtime_r instead of localtime()

 

View solution in original post

3 REPLIES 3
Pavel A.
Super User

Try to use localtime_r instead of localtime()

 

SharonVEC
Associate II

You are correct! this solved my issue.

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

Pavel A.
Super User

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.