【发布时间】:2011-06-27 18:06:42
【问题描述】:
我有一个获取系统时间的功能。函数定义如下。
int getSystemTime(struct timeval tv, void * tz);{
DWORD milliseconds;
milliseconds = timeGetTime();
tv->tv_sec = milliseconds / 1000;
tv->tv_usec = (milliseconds % 1000) * 1000;
return 0;
}
问题如下:
1.error: identifier DWORD is undentified .
2.error: identifier timeGetTime() is undefined.
3.error: identifier suseconds_t is undefined.
我尝试在定义 DWORD 的位置包含 windef.h。但问题是,我收到如下错误:
1. error: identifier PCONTEXT is undefined.
包含时间的头文件是time.h。这里定义的时间是:
#ifndef _WINSOCK_H
struct timeval {
time_t tv_sec;
suseconds_t tv_usec;
};
你能告诉我我应该怎么做才能让这个功能在windows环境下运行吗?
[编辑]
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#ifdef HAVE_MMSYSTEM_H
#include <mmsystem.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
【问题讨论】:
标签: c visual-studio visual-studio-2010 compiler-warnings