Julek said:
Is there any simple library that can return a systemtime in a
resolution of max. 10ms, working on both Windows XP and modern Linux?
time() works on both but has a resolution of 1s. There is
GetSystsmTime on Windows with 10ms resolution, there are probably also
some functions for Linux - but maybe there is some library works on
both these OSes?
don't use a library for what you can trivially do yourself...
using libs in this case does little more than create external dependencies
for which any potential users of said code may be forced to deal with later.
a lib is good if it is known to be commonly or near universally available,
is already in use of a project, or represents a non-trivial amount of work,
but otherwise I feel use of libs is ill-advised, as it may create
portability issues (and people trying to dig around online to find "X
obscure library no one has heard of", or figuring out how to do likewise by
looking at the code and figuring out what the API calls do...)..
now, maybe of some help:
#ifdef linux
....
gettimeofday(...);
....
#endif
or, maybe even:
#if defined(linux) || defined(__BSD__) || defined (__MACOSX__) || ...
....
gettimeofday(...);
....
#endif
my personal suggestion is to create a function, or maybe collection of them,
which provide a consistent interface to OS-specific behaviors, and keep any
OS specific parts confined to these functions.