【问题标题】:Weird error when trying to build尝试构建时出现奇怪的错误
【发布时间】:2023-03-07 02:03:01
【问题描述】:

我在一个名为 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

但我不断收到这些错误:

有谁知道问题出在哪里?

【问题讨论】:

    标签: ios objective-c compilation compiler-errors time.h


    【解决方案1】:

    问题可能与编译时未找到 C++ 标准库有关

    您可以尝试以下方法:

    • 为您的项目添加一个空的 .mm 文件! 确保在构建设置中将 C++ 标准库设置为 libstdc++(GNU c++ 标准库)
      参考:https://stackoverflow.com/a/19250215/4557505
      else
    • 将 -lstdc++ 添加到其他链接器标志!在构建设置中
      else
    • 在构建阶段添加 libstdc++.dylib/tbd 和 libstdc++.6.dylib/tbd -> 将二进制文件与库链接

    【讨论】:

      【解决方案2】:

      所以我找到了答案,可能是因为我有一个框架,里面有一个名为time.h 的标题,它是保存名称。我将我的文件更改为mytime.h,它编译得很好。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-31
        • 2023-01-13
        • 2021-04-27
        • 2015-12-21
        • 1970-01-01
        相关资源
        最近更新 更多