Saturday, April 16, 2016

Weird error when trying to build

Leave a Comment

I have this code in a class called ctime:

#include <__config> #include <time.h>  #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif  _LIBCPP_BEGIN_NAMEPSACE_STD  using ::clock_t; using ::size_t; using ::time_t; using ::tm; using ::clock; using ::difftime; using ::mktime; using ::time; using ::asctime; using ::ctime; using ::gmtime; using ::localtime; using ::strftime;  _LIBCPP_END_NAMESPACE_STD 

But I keep getting these errors:

errors

Anyone knows what the problem is?

2 Answers

Answers 1

Issue may be related to C++ standard library not found at the compile time

You can try the following ways:

  • Add an empty .mm file to you project! Ensure that C++ Standard Library is set to libstdc++ (GNU c++ standard library) in the Build Settings
    Ref: http://stackoverflow.com/a/19250215/4557505
    else
  • add -lstdc++ to Other Linker Flags! in the build settings
    else
  • add libstdc++.dylib/tbd and libstdc++.6.dylib/tbd in the build phases -> Link Binary with Library

Answers 2

So I found the answer, it was probably because I had a framework with a header inside called time.h which is saved name. I changed my file to mytime.h and it compiled perfectly.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment