Hi!
I'm writing a function that uses the timeval structure but it gives me some problems...
Here is the code:
Code:
#if defined(__unix__) || defined(unix)
#include <time.h>
#include <sys/time.h>
#else /* if win32 */
#include <windows.h>
#endif /* unix */
unsigned long get_msec(void) {
#if defined(__unix__) || defined(unix)
//static struct
struct timeval timev, first_timeval;
gettimeofday(&timev, 0);
if(first_timeval.tv_sec == 0) {
first_timeval = timev;
return 0;
}
return (timev.tv_sec - first_timeval.tv_sec) * 1000 + (timev.tv_usec - first_timeval.tv_usec) / 1000;
#else
return GetTickCount();
#endif /* unix */
}
And the errors I have:
/Users/ermengol87/Documents/EPFL/Advance Computer Graphics/Prova Mandelbrot/../../../../Downloads/sdr_fract 2/timer.c:12:0 /Users/ermengol87/Documents/EPFL/Advance Computer Graphics/Prova Mandelbrot/../../../../Downloads/sdr_fract 2/timer.c:12: error: storage size of 'timev' isn't known
/Users/ermengol87/Documents/EPFL/Advance Computer Graphics/Prova Mandelbrot/../../../../Downloads/sdr_fract 2/timer.c:12:0 /Users/ermengol87/Documents/EPFL/Advance Computer Graphics/Prova Mandelbrot/../../../../Downloads/sdr_fract 2/timer.c:12: error: storage size of 'first_timeval' isn't known
I'm using OS X Snow Leopard and the last version of Xcode.
I hope somebody help me!