使用boost的问题,出现stl的ctime头文件编译错误,如clock_t不是全局的等,怎样解决?附带详细的错误说明

FirryHere 2012-02-29 12:10:31
是不是还有time.h文件被先于vcinc中time.h包含了?还是boost中有宏控制的?在国外论坛里面遇到过类似的,但是没有解决。
编译错误如下:
D:\Program Files\Microsoft Visual Studio 8\VC\include\ctime(18) : error C2039: 'clock_t' : is not a member of '`global namespace''
1>D:\Program Files\Microsoft Visual Studio 8\VC\include\ctime(18) : error C2873: 'clock_t' : symbol cannot be used in a using-declaration
1>D:\Program Files\Microsoft Visual Studio 8\VC\include\ctime(20) : error C2039: 'asctime' : is not a member of '`global namespace''
1>D:\Program Files\Microsoft Visual Studio 8\VC\include\ctime(20) : error C2873: 'asctime' : symbol cannot be used in a using-declaration
1>D:\Program Files\Microsoft Visual Studio 8\VC\include\ctime(20) : error C2039: 'clock' : is not a member of '`global namespace''
1>D:\Program Files\Microsoft Visual Studio 8\VC\include\ctime(20) : error C2873: 'clock' : symbol cannot be used in a using-declaration
1>D:\Program Files\Microsoft Visual Studio 8\VC\include\ctime(20) : error C2039: 'ctime' : is not a member of '`global namespace''
1>D:\Program Files\Microsoft Visual Studio 8\VC\include\ctime(20) : error C2873: 'ctime' : symbol cannot be used in a using-declaration
1>D:\Program Files\Microsoft Visual Studio 8\VC\include\ctime(21) : error C2039: 'difftime' : is not a member of '`global namespace''
1>D:\Program Files\Microsoft Visual Studio 8\VC\include\ctime(21) : error C2873: 'difftime' : symbol cannot be used in a using-declaration
1>D:\Program Files\Microsoft Visual Studio 8\VC\include\ctime(21) : error C2039: 'gmtime' : is not a member of '`global namespace''
1>D:\Program Files\Microsoft Visual Studio 8\VC\include\ctime(21) : error C2873: 'gmtime' : symbol cannot be used in a using-declaration
1
...全文
860 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
kenkasumar 2012-04-27
  • 打赏
  • 举报
回复
你搜索下自己的工程中是不是有"time.h"文件,和Windows系统的冲突了...
FirryHere 2012-03-03
  • 打赏
  • 举报
回复
还有interlockedincrement 无法找到之类的错误。
程序员小迷 2012-02-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 cxsjabcabc 的回复:]

boost加入后,经常出现不在std里面的一个符号,
其实最终原因都是自己写的代码有写过的地方,导致编译器跟着误解了。。
[/Quote]

”写过“ 写错了,改为 “写错”
程序员小迷 2012-02-29
  • 打赏
  • 举报
回复
boost加入后,经常出现不在std里面的一个符号,
其实最终原因都是自己写的代码有写过的地方,导致编译器跟着误解了。。
闲的每日C 2012-02-29
  • 打赏
  • 举报
回复

#if _GLOBAL_USING && !defined(RC_INVOKED)
_STD_BEGIN
using _CSTD clock_t; using _CSTD size_t;
using _CSTD time_t; using _CSTD tm;
using _CSTD asctime; using _CSTD clock; using _CSTD ctime;
using _CSTD difftime; using _CSTD gmtime; using _CSTD localtime;
using _CSTD mktime; using _CSTD strftime; using _CSTD time;
_STD_END
#endif /* _GLOBAL_USING */

从ctime中看到是这样的。
再看你的报错,就知道你引入了_CSTD的预定义,且为空。
ctime的clock_t在C++环境中应该在std::命名空间下。
所以你要找一下,是哪里引入了#define _CSTD

65,198

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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