我用VC++2008,想问为什么找不到

dearglucose 2008-04-08 12:48:05
谢谢!
...全文
4240 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
沭水河畔 2008-12-06
  • 打赏
  • 举报
回复
这是一个Linux环境下的头文件,楼主可以试试mingw或者Cygwin。或者直接用C-Free,自带mingw。
hias_asia 2008-11-28
  • 打赏
  • 举报
回复
直接移植Cygwin到VC中。
mayunshui 2008-10-13
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 Chiyer 的回复:]
C/C++ code


gettimeofday 是unix/linux上的
windows上用

timeGetTime
或者
GetTickCount
之类的吧,

自己google下

s
[/Quote]
差不多
奔跑吧猴哥 2008-09-23
  • 打赏
  • 举报
回复
建议使用跨平台库ACE + Qt
万里石塘 2008-09-22
  • 打赏
  • 举报
回复
初学者,往往是别处找来的代码,而编代码的人又不够专业,根本不注明编译环境,结果出现了古老的TC环境下代码被copy到VC++6.0 甚至VS里面,编译:找不到**头文件,有人甚至煞费苦心地在网上找到了**头文件,放在目录里,结果还是不行!!
meiZiNick 2008-05-01
  • 打赏
  • 举报
回复
等待牛人来答.
Treazy 2008-04-10
  • 打赏
  • 举报
回复
现在要做一个合格的程序员还真难啊
mayunshui 2008-04-10
  • 打赏
  • 举报
回复
sys/time...
在linux 上有,
是系统调用,
window 下,没有
mymtom 2008-04-09
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 Treazy 的回复:]
现在怎么这样的问题那么多?

不同平台上的东西拿来就用,也不搞明白一下

我是不是该问,为什么?
[/Quote]
这个说明时代进步了!
在我学C语言的年代. 谭老板的书和TC 2.0风靡全国. 那里知道还有不同的平台嘛.
Treazy 2008-04-09
  • 打赏
  • 举报
回复
现在怎么这样的问题那么多?

不同平台上的东西拿来就用,也不搞明白一下

我是不是该问,为什么?
mymtom 2008-04-09
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 dearglucose 的回复:]
沒有的話,請問我怎么可以使用gettimeofday??
thanks
[/Quote]

/*-
* Copyright (C) 2008 mymtom (mymtom@hotmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: src/lib/libtrace/gettimeofday.c,v 1.1 2008/03/28 12:08:44 mymtom Exp $
*/

#include <time.h>
#ifdef WIN32
# include <windows.h>
#else
# include <sys/time.h>
#endif

#ifdef WIN32
int
gettimeofday(struct timeval *tp, void *tzp)
{
time_t clock;
struct tm tm;
SYSTEMTIME wtm;

GetLocalTime(&wtm);
tm.tm_year = wtm.wYear - 1900;
tm.tm_mon = wtm.wMonth - 1;
tm.tm_mday = wtm.wDay;
tm.tm_hour = wtm.wHour;
tm.tm_min = wtm.wMinute;
tm.tm_sec = wtm.wSecond;
tm. tm_isdst = -1;
clock = mktime(&tm);
tp->tv_sec = clock;
tp->tv_usec = wtm.wMilliseconds * 1000;

return (0);
}
#endif /* WIN32 */

简单测试程序:

#include <stdio.h>
#include <stdlib.h>

#include <time.h>
#ifdef WIN32
# include <windows.h>
#else
# include <sys/time.h>
#endif

int gettimeofday(struct timeval *tp, void *tzp);

#if defined(_MSC_VER) && !defined(snprintf)
#define snprintf _snprintf
#endif

int main(int argc, char *argv[])
{
struct timeval tv;
char buf[] = "1970-01-01 00:00:00.000";

(void)gettimeofday(&tv, 0);
(void)strftime(buf, sizeof(buf) - 1, "%Y-%m-%d %H:%M:%S.000",
(localtime(&tv.tv_sec)));
(void)snprintf(buf + 20, 3, "%03d", (int)(tv.tv_usec / 1000));
(void)printf("%s\n", buf);

return (0);
}
星羽 2008-04-08
  • 打赏
  • 举报
回复


gettimeofday 是unix/linux上的
windows上用

timeGetTime
或者
GetTickCount
之类的吧,

自己google下
dearglucose 2008-04-08
  • 打赏
  • 举报
回复
沒有的話,請問我怎么可以使用gettimeofday??
thanks
星羽 2008-04-08
  • 打赏
  • 举报
回复
vc 没有这个

直接

#include "time.h"
fox000002 2008-04-08
  • 打赏
  • 举报
回复
vc 哪来的 <sys/time.h>

从 VC6 --> VC2005 --> VC2008 都是没有的

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧