MISRA Discussion Forums
Alternative to time.h - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.21 Standard libraries (https://forum.misra.org.uk/forumdisplay.php?fid=176)
+---- Thread: Alternative to time.h (/showthread.php?tid=1052)



Alternative to time.h - gwillits - 23-04-2014

Rule 21.10 : The Standard Library time and date functions shall not be used.

I'm relatively new to C, new to MISRA guidelines, and trying to wrap my head around how to substitute for the time.h library. I've internet-searched my brains out looking for some clue as to what people do for time functions. Do they completely re-implement their own code in order to avoid the "unspecified, undefined and implementation-defined behaviours" of the standard library?

Given the expansion of Rationale of the 2012 over 2004 documentation, it surprised me there's no suggestions of what best practice alternatives are to the things which "shall not be used".

Anyway, I'd appreciate anyone's input as to what MISRA conforming code does for time functionality.

Many thanks,

-- gw


Re: Alternative to time.h - misra-c - 25-06-2014

is banned as it has unspecified, undefined and implementation-defined properties.

After reviewing the properties of the implementation, you may decide that the best course of action is to use , in which case a deviation will be required.

This may be preferable to writing such functions from scratch or using an unproven third party library.