【COCOS2DX-ANDROID-游戏开发之十九】android编译之ctime:66: error: ‘::clock_t’ has not been declared
来源:互联网 发布:js获取div name 编辑:程序博客网 时间:2024/04/28 07:56
编译android 报错,ctime:66: error: ‘::clock_t’ has not been declared,诡异的问题如下图:
报一个gnu的C++标准库的ctime的错误
程序中根本木有调用<ctime>,那这个诡异的问题是怎么来的呢?
后来发现我有一个类Time.h和Time.cpp,对就是这货,且不管为什么GNU为什么不识别大小写,为什么和标准库的<time.h>起冲突,但这个诡异的问题足以告诉我们:
一定不要起类名和标准库一样的名字,否则暂时木有问题,早晚会自食苦果的~~
------------------------------------------------------------
国外的盆友也遇到类似的问题:给个copy
So I lost a bit of time to this compiler error coming from a MacBook and OSX 10.5:
/usr/include/c++/4.0.0/ctime:66: error: ‘::clock_t’ has not been declared
/usr/include/c++/4.0.0/ctime:68: error: ‘::tm’ has not been declared
/usr/include/c++/4.0.0/ctime:70: error: ‘::clock’ has not been declared
/usr/include/c++/4.0.0/ctime:71: error: ‘::difftime’ has not been declared
/usr/include/c++/4.0.0/ctime:72: error: ‘::mktime’ has not been declared
/usr/include/c++/4.0.0/ctime:73: error: ‘::time’ has not been declared
/usr/include/c++/4.0.0/ctime:74: error: ‘::asctime’ has not been declared
/usr/include/c++/4.0.0/ctime:75: error: ‘::ctime’ has not been declared
/usr/include/c++/4.0.0/ctime:76: error: ‘::gmtime’ has not been declared
/usr/include/c++/4.0.0/ctime:77: error: ‘::localtime’ has not been declared
/usr/include/c++/4.0.0/ctime:78: error: ‘::strftime’ has not been declared
/usr/include/c++/4.0.0/bits/locale_facets.tcc: In member function ‘_InIter std::time_get<_CharT, _InIter>::_M_extract_via_format(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, tm*, const _CharT*) const’:
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1794: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1801: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1809: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1816: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1828: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1835: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1838: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1850: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1855: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1863: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1867: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1887: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1923: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc:1931: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc: In member function ‘virtual _InIter std::time_get<_CharT, _InIter>::do_get_weekday(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, tm*) const’:
/usr/include/c++/4.0.0/bits/locale_facets.tcc:2157: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc: In member function ‘virtual _InIter std::time_get<_CharT, _InIter>::do_get_monthname(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, tm*) const’:
/usr/include/c++/4.0.0/bits/locale_facets.tcc:2203: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.0.0/bits/locale_facets.tcc: In member function ‘virtual _InIter std::time_get<_CharT, _InIter>::do_get_year(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, tm*) const’:
/usr/include/c++/4.0.0/bits/locale_facets.tcc:2230: error: invalid use of undefined type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
The answer is that is that the Mac OS X GCC compile environment is funny about case sensitivity and redefining things. In this case somewhere in my -I/mylibpath/include/ was a file Time.h. The system saw this as a redefinition of time.h and got all confused. Note that I didn’t even use that Time.h in my main.c, nor did any header I used call it. It just saw the file from my -I/path/. I renamed the file to oTime.h and did a find/replace on all affected library files and I was on to the next compiler error. Of course that turned out to be an undefined INT_MAX. Same problem different file. In the includes, there was a Limits.h that included limits.h but added to defines. Once again, Limits.h becomes oLimits.h and a find/replace (I’m playing with TextWrangler for this). Good luck.
- 【COCOS2DX-ANDROID-游戏开发之十九】android编译之ctime:66: error: ‘::clock_t’ has not been declared
- error: ‘::WSAGetLastError’ has not been declared
- QT,error: '::ioctl' has not been declared,调用ioctl
- ubuntu装opencv error: ‘NppiGraphcutState‘ has not been declared
- Thrift编译错误('::malloc' has not been declared)
- 【COCOS2DX-ANDROID-游戏开发之十八】编译android版本之添加预编译宏
- Android错误之Location of the Android SDK has not been setup in the preferences
- Android游戏开发之旅(十九) 分辨率大全
- ::system has not been declared 的问题
- cocos eclipse TouchEventType' has not been declared
- version `GLIBCXX_3.4.14' not found, 及shared_ptr.h error: '_Lock_policy' has not been declared 问题
- 【COCOS2DX-ANDROID-游戏开发之十六】之 APK签名,打包
- 【COCOS2DX-ANDROID-游戏开发之二二】之 调用Cocos2dxGLSurfaceView
- android初学之Android异常之 Warning: Activity not started, its current task has been brought to the front
- error: ‘std::memset’ has not been declared问题的解放办法
- windows平台theano在安装gcc后出现error: '::hypot' has not been declared
- cudalegacy/src/graphcuts.cpp:120:54: error: ‘NppiGraphcutState’ has not been declared
- 安装opencv出现:cudalegacy/src/graphcuts.cpp:120:54: error: ‘NppiGraphcutState’ has not been declared
- SDL源码阅读笔记(2) video dirver的初始化及选择
- 算法杂货铺——分类算法之决策树(Decision tree) - T2噬菌体
- Tomcat6.0源码学习--启动框架
- Break,continue,returne的区别和使用
- 算法复杂度
- 【COCOS2DX-ANDROID-游戏开发之十九】android编译之ctime:66: error: ‘::clock_t’ has not been declared
- 没有文件扩展“.js”的脚本引擎问题解决
- 五险一金用处及投放技巧(工作上的那些事儿)
- solr 使用
- SDL源码阅读笔记(3)渲染模块
- zoj 3736 Pocket Cube(2013亚洲区域赛 长沙站 K)
- android-x86 的安装和设置使用笔记
- Chapter 1 | Arrays and Strings--字符串的翻转与去重
- 暴力求解法-双基回文数