bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "getTicks() in ms" to add for WIN32 and Linux to commonc++?


From: Marc Boris Dürner
Subject: Re: "getTicks() in ms" to add for WIN32 and Linux to commonc++?
Date: Fri, 2 Jan 2004 15:32:25 +0100 (MET)

Hello Wolfgang, 
 
There are Date and Time classes in CommonC++ that may do what you need. If
they 
dont, I am sure David appreciates a patch. 
 
Marc 
 
 
On Friday 02 January 2004 13:49, Wolfgang wrote: 
> Would it make sense to add a getTicks() type function to the CommonC++ 
> framework? Or do you think it is so trivial that it does not need to be 
> there? I run into this recently when porting a project from linux to win32

> using commonc++. 
> Here a draft for for win32 and linux. 
> 
> 
> 
> #ifndef WIN32 
> #include <sys/time.h> 
> #else 
> #include <time.h> 
> #include <windows.h> 
> #endif //win32 
> 
> 
> //return number of ticks in ms 
> long getTicks(); 
> 
> 
> ifdef WIN32 
> long getTicks() { 
>       return GetTickCount(); 
> }; 
> #else 
> long getTicks() { 
>       long ticks; 
>       struct timeval now; 
>       gettimeofday(&now, NULL); 
>       ticks = now.tv_sec * 1000l; 
>       ticks += now.tv_usec / 1000l; 
>       return ticks; 
> }; 
> #endif 
> 

-- 
+++ GMX - die erste Adresse für Mail, Message, More +++
Neu: Preissenkung für MMS und FreeMMS! http://www.gmx.net






reply via email to

[Prev in Thread] Current Thread [Next in Thread]