【发布时间】:2015-11-23 19:24:40
【问题描述】:
#ifdef WIN32
#else
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <conio.h>
#include <stdio.h>
#include <sys/timeb.h>
#include <time.h>
#include <conio.h>
#include <unistd.h>
#endif
int main()
{
long time_ms;
#ifdef WIN32
struct _timeb timebuffer;
_ftime( &timebuffer );
time_ms = (long)timebuffer.time * 1000 + (long)timebuffer.millitm;
printf("Windows timing %ld", time_ms);
#else
struct timeval t1;
struct timezone tz;
gettimeofday(&t1, &tz);
time_ms = (t1.tv_sec) * 1000 + t1.tv_usec / 1000;
printf("Other timing %ld", time_ms);
#endif
// return time_ms;
}`
这是完整代码的一部分,但是当我单独运行时遇到相同的错误,无法找到解决方案。 我附上了错误屏幕截图
【问题讨论】:
-
删除
#ifdef WIN32和#else和#endif。 -
您没有包含任何用于 Windows 编译的文件。所以它不识别结构和功能。
-
屏幕截图显示您正在使用 Dev-C++。不。使用带有 MinGW 的 CodeBlocks 或 Visual Studio 的 Express/Community 版本(均免费)。