使用Visual C 2008时如何解决未处理的异常错误?
作者:互联网
有人可以帮助我解决使用Visual C 2008时出现的未处理异常错误吗?错误显示如下:在time.exe中0x00411690未处理的异常:0xC0000005:访问冲突读取位置0x00000008
一些细节:
-tm 0x00000000 {tm_sec = ??? tm_min = ??? tm_hour = ??? …} Tm值 *
tm_sec CXX0030:错误:无法评估表达式
…
实际上,当我过去使用Visual c 6时,没有任何错误,程序运行正常.但是现在当我使用Visual 2008时,我遇到了这个Unhandled异常错误.
这是程序:
...
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag = 0;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
tmpres /= 10; /*convert into microseconds*/
/*converting file time to unix epoch*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
return 0;
}
uint32_t stampstart()
{
struct timeval tv;
struct timezone tz;
struct tm *tm;
uint32_t start;
gettimeofday(&tv, &tz);
tm = localtime(&tv.tv_sec);
printf("TIMESTAMP-START\t %d:%02d:%02d:%d (~%d ms)\n", tm->tm_hour,
tm->tm_min, tm->tm_sec, tv.tv_usec,
tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
tm->tm_sec * 1000 + tv.tv_usec / 1000); /////---debugger stops here---
start = tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
tm->tm_sec * 1000 + tv.tv_usec / 1000;
return (start);
}
感谢您的答复:
解决方法:
尝试类似…
tm = localtime(&tv.tv_sec);
if(tm)
{
printf("TIMESTAMP-START\t %d:%02d:%02d:%d (~%d ms)\n", tm->tm_hour,
tm->tm_min, tm->tm_sec, tv.tv_usec,
tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
tm->tm_sec * 1000 + tv.tv_usec / 1000);
start = tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
tm->tm_sec * 1000 + tv.tv_usec / 1000;
}
else
{
// failed to retrive local time
}
标签:c-3,c,exception-handling,visual-c,visual-studio-2008 来源: https://codeday.me/bug/20191011/1895578.html