如何解决与MacOSX上全局命名空间错误中没有成员相关的丢失时间? [英] How to fix missing time related no member in global namespace errors on MacOSX?

查看:331
本文介绍了如何解决与MacOSX上全局命名空间错误中没有成员相关的丢失时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Maverick 10.9的命令行上编译项目.该项目可以在Linux上完美编译.显然,在MacOSX上ctime似乎存在问题.错误是

I'm trying to compile a project on the command line on Maverick 10.9. The project compiles perfectly on Linux. Apparently, there seems to be an issue with ctime on MacOSX. The errors are

$ make
Compiling src//core/AbstractARAClient.cpp
In file included from src//core/AbstractARAClient.cpp:5:
In file included from include/AbstractARAClient.h:8:
In file included from include/ARAMacros.h:14:
In file included from include/Address.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/sstream:174:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ostream:131:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__locale:18:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/mutex:176:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__mutex_base:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/chrono:279:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctime:56:9: error: no member named
      'clock_t' in the global namespace
using ::clock_t;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctime:58:9: error: no member named
      'time_t' in the global namespace; did you mean 'size_t'?
using ::time_t;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stddef.h:42:23: note: 
      'size_t' declared here
typedef __SIZE_TYPE__ size_t;

In file included from src//core/AbstractARAClient.cpp:5:
In file included from include/AbstractARAClient.h:8:
In file included from include/ARAMacros.h:14:
In file included from include/Address.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/sstream:174:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ostream:131:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__locale:18:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/mutex:176:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__mutex_base:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/chrono:279:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctime:60:9: error: no member named
      'clock' in the global namespace
using ::clock;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctime:61:9: error: no member named
      'difftime' in the global namespace
using ::difftime;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctime:62:9: error: no member named
      'mktime' in the global namespace
using ::mktime;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctime:63:9: error: no member named
      'time' in the global namespace
using ::time;

我已经在网上搜索过,如果项目中有名为"time.h"的标头,则似乎存在问题(就像该项目中的情况一样).通常,ctime的实际实现不完整也存在问题(但通常人们通过xcode指代安装命令行实用程序).

I've searched the web and there seems to be an issue if there are headers in a project which are named 'time.h' (like it is the case in this project). There also seems generally to be a problem with an actual incomplete implementation of ctime (but generally people refer to install command line utils via xcode).

我想知道一般问题是什么,最后是如何在Mac上实际编译代码.相比之下,对于存储库中的代码,我在第53行的Makefile中添加了一个stdlib选项

I'm wondering what the general issue is and finally how to actually compile the code on mac. In contrast, to the code in the repository, I've added to the Makefile in line 53 a stdlib option

CFLAGS_DEBUG = -g -Wall -stdlib=libc++

已经在Makefile的前一行中设置了C ++ 11选项.

The C++11 option is already set in a previous line of the Makefile.

TIA

推荐答案

答案或多或少是显而易见的.该项目包含标头Time.h(和相应的类Time).不幸的是,MacOSX文件系统不区分大小写,这意味着它与/usr/include中现有的time.h冲突.

The answer is more or less obvious. The project contains a header Time.h (and corresponding class Time). Unfortunately, the MacOSX file system is case insensitive, meaning that this conflicts with the existing time.h in /usr/include.

您可以在Time.h之前预先包含系统time.h(意为#include <ctime>),也可以将文件重命名为其他名称(例如MyTime.h).

You can either include the systems time.h (meaning #include <ctime>) beforehand the Time.h or simply rename your file to something else (e.g. MyTime.h).

这篇关于如何解决与MacOSX上全局命名空间错误中没有成员相关的丢失时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆