This is more a general question. How is the coupling done between the time() c-function and the underlying hardware? Suppose that you compile for a microcontroller not containing any RTC, what value do you get back? Or if you use your own RTC that keeps running with battery on a separate chip? How do you update time() after repowering? Is there any method for redirecting?
I did a trial in Mbed with RTC and time() function with MCU_STM32U575xG.
There is no coupling "done". You have to "do it".
I would expect a linking error, or maybe I would expect
time()to return(time_t)-1witherrnoset toENOSYS.Returning -1 and ENOSYS is the default
nosysimplementation ofnewlibC standard library implementation so commonly used with GNUarm-none-eabi-gcccompiler toolchain here https://github.com/bminor/newlib/blob/master/libgloss/libnosys/gettod.c#L18 .In the case of mbed-os, time function is implemented here https://github.com/mbed-ce/mbed-os/blob/master/platform/source/mbed_rtc_time.cpp#L120 . The specifics of the function and what
_rtc_read()function calls is configured with mbed-os configuration. You have to configure mbed-os and provide it with the configuration and compile with mbed-os.Bottom line, there is no coupling. You have to make the coupling if you want it.