I'm developing a c++ app for a cross platform 32 bit embedded system(windows and linux). For one needed functionality I need to calculate a time difference in milliseconds. Firstly the biggest precision that epoch timestamp give for 32bit systems, is that of a second. The majority of relevant answers that I came across are either 64bit related like the use of std::clock or std::chrono like:
std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count();
Or system sprecific using
#include <sys/time.h>
or the GetSystemTime function on windows. I also checked the poco related time functions but they are also based on using 64bit variables. Can this be done with an existing standard or external c++ library or should I follow different approach?
chrono::system_clock
often has 1s precision andchrono::high_resolution_clock
doesn't start at epoch. – rustyx