How to fix missing member time related to missing member in global namespace errors on MacOSX?

I am trying to compile a project on the command line on Maverick 10.9. The project compiles fine on Linux. It seems that there is a problem with ctime on MacOSX. Mistakes

$ 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; 

I searched on the Internet and there seems to be a problem if the project has headers named "time.h" (as is the case with this project). In general, there is also a problem with the actual incomplete implementation of ctime (but, as a rule, people refer to installation command-line commands through xcode).

I am wondering what the general problem is, and finally, how to compile the code on a Mac. Unlike the code in the repository, I added the stdlib parameter to line 53 of the Makefile

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

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

TIA

+8
c ++ clang ++ macos ctime
source share
2 answers

The answer is more or less obvious. The project contains the title Time.h (and the corresponding Time class). Unfortunately, the MacOSX file system is case insensitive, which means that it conflicts with the existing Time.h in /usr/include .

You can either enable the system time.h (value #include <ctime> ) in advance of Time.h , or simply rename the file to another (for example, MyTime.h ).

+7
source share

There is another way to solve this problem, which IMHO is better. I am writing this so that I can easily find the answer the next time I hit this error and forget the solution (after a couple of years?)

Go to Xcode and remove the project files included in the Headers section from the build phases.

This will prevent the unacceptable action of the compiler, including from your space (which should only be available (or at least ordered last) via "Time.h")

This essentially says Xcode "No, I don't want to look for my own headers as if they were a library, because it's my own project"

It probably has other secondary effects, but, at least for my purposes, it's better than renaming my "Time.h"

+2
source share

All Articles