Monday 15 March 2010

Migrating c program from linux to windows -



Migrating c program from linux to windows -

i have problem migrating working programme written on linux windows. clean little bit next code snippet give me error.

code snippet:

... struct timeval mytime; gettimeofday(&mytime, (struct timezone*)0); tseconds = (double) (mytime.tv_sec + mytime.tv_usec*1.0e-6); ...

stacktrace:

error 1 error c2079: 'mytime' uses undefined struct 'timeval' warning 2 warning c4013: 'gettimeofday' undefined; assuming extern returning int error 3 error c2224: left of '.tv_sec' must have struct/union type error 4 error c2224: left of '.tv_usec' must have struct/union type 5 intellisense: incomplete type not allowed 6 intellisense: incomplete type not allowed 7 intellisense: incomplete type not allowed

if help me grateful!

@dave link add together code below snippets:

const __int64 delta_epoch_in_microsecs = 11644473600000000; struct timeval2 { __int32 tv_sec; __int32 tv_usec; }; struct timezone2 { __int32 tz_minuteswest; /* minutes w of greenwich */ bool tz_dsttime; /* type of dst correction */ }; int gettimeofday(struct timeval2 *tv/*in*/, struct timezone2 *tz/*in*/) { filetime ft; __int64 tmpres = 0; time_zone_information tz_winapi; int rez = 0; zeromemory(&ft, sizeof(ft)); zeromemory(&tz_winapi, sizeof(tz_winapi)); getsystemtimeasfiletime(&ft); tmpres = ft.dwhighdatetime; tmpres <<= 32; tmpres |= ft.dwlowdatetime; /*converting file time unix epoch*/ tmpres /= 10; /*convert microseconds*/ tmpres -= delta_epoch_in_microsecs; tv->tv_sec = (__int32) (tmpres*0.000001); tv->tv_usec = (tmpres % 1000000); //_tzset(),don't work properly, utilize gettimezoneinformation rez = gettimezoneinformation(&tz_winapi); tz->tz_dsttime = (rez == 2) ? true : false; tz->tz_minuteswest = tz_winapi.bias + ((rez == 2) ? tz_winapi.daylightbias : 0); homecoming 0; }

and code builds correctly :)!

c linux windows visual-studio-2013 openmp

No comments:

Post a Comment