cancel
Showing results for 
Search instead for 
Did you mean: 

How/where to put option in STM32CubeIDE gcc -D_TIME_BITS=64

David_
Associate III

Is the STM32CubeIDE defaults 64 bits in unix time?  if not, how/where to put gcc command line option in STM32CubeIDE "gcc -D_TIME_BITS=64".  Supposedly, this will redirect unix time to be 64 bit instead of traditional 32 bit that will overflow in year 2038.  TIA

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

You can test number of bits of time_t in the standard C library with sizeof(time_t).

The underlying type for time_t  that has been used for compilation of the newlib (the C runtime library of the ARM toolchain, bundled with CubeIDE) is defined in newlib.h

 

#include <newlib-nano/newlib.h>

#ifndef  _WANT_USE_LONG_TIME_T 
// time_t likely is LONGLONG = 64 bit. this is default.
#else
// time_t likely is LONG (32 bit)
#endif

 

Usually located in [STM32CubeIDE]/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.xxxxxxxxxx/tools/arm-none-eabi/include/newlib-nano/newlib.h

You cannot redefine this size in your project with any macro or C option, as the library has already been built and available for you in object form.

If you want different number of bits for time, you can define any typedef and your own time functions.

 

 

View solution in original post

3 REPLIES 3
STTwo-32
ST Employee

Hello @David_ 

Can you give more details about your question. I'm not understanding this very well.

Best Regards.

STTwo-32

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Sorry my question not clear. 

I believe STM32Cube use (unix for ARM) gcc compiler and make file. 

If one execute gcc compiler on (unix) command prompt CLI, after gcc, there is a string of 'switches' or 'options' to tell the compiler to do something, like where is source file, where to save the compiled file, c optimization level, etc. 

I was told the "-D_TIME_BITS=64" switch direct compiler to use 64 bits to hold the unix epoch time instead of the original design that use 32 bits and will overflow at year 2038.

I am seeking advises on where to put that "-D_TIME_BITS=64" in many 'configuration' tab in STM32Cube so that it will pass onto gcc compiler during the IDE/Make process. 

Many thanks

Pavel A.
Evangelist III

You can test number of bits of time_t in the standard C library with sizeof(time_t).

The underlying type for time_t  that has been used for compilation of the newlib (the C runtime library of the ARM toolchain, bundled with CubeIDE) is defined in newlib.h

 

#include <newlib-nano/newlib.h>

#ifndef  _WANT_USE_LONG_TIME_T 
// time_t likely is LONGLONG = 64 bit. this is default.
#else
// time_t likely is LONG (32 bit)
#endif

 

Usually located in [STM32CubeIDE]/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.xxxxxxxxxx/tools/arm-none-eabi/include/newlib-nano/newlib.h

You cannot redefine this size in your project with any macro or C option, as the library has already been built and available for you in object form.

If you want different number of bits for time, you can define any typedef and your own time functions.