gpt4 book ai didi

c++ - xcode 无法使用未知类型命名空间构建 C++

转载 作者:行者123 更新时间:2023-11-30 05:15:53 25 4
gpt4 key购买 nike

  • 我已经在 Xcode 8.2.1 中创建了一个带有桥接头文件的 C++ 项目。
  • 我已将 Point3.hpp 和 Point3.cpp 文件添加到共享文件夹中。
  • cpp 和 cpp 文件的类型(在身份和类型检查器中)分别是 Default - C++ Source 和 Default - C++ Header。
  • LLVM 8.0 语言设置为:
    • C++11 [-std=c++11]
    • libc++(支持 C++11 的 LLVM C++ 标准库)

当我尝试构建项目时,我发现出现以下错误:

enter image description here

我曾尝试搜索以找到解决此问题的信息,但大多数似乎都与编译源代码有关,该源代码是 objective-C 和 C++ 的组合,而该项目被设置为带有 C++ 桥的 Swift3 项目。 Source code

ex3-Bridging-Header.h

#import "../../../Shared/ex3/math/Point3.cpp"

enter image description here

Point3.cpp

#include "Point3.hpp"
using namespace EX3;
Point3::Point3()
{
} ...

enter image description here

Point3.hpp

#ifndef EX3_POINT3_HPP
#define EX3_POINT3_HPP
namespace EX3
{
class Point3
{
public:
Point3(); ...

enter image description here

编译器设置

enter image description here

最佳答案

在继续寻找之后,我终于设法找到了一个可行的解决方案。可能有其他方法可以实现此目的,但我通过将 C++ 路由到 Objective C 层来修复它。虽然这看起来有点笨拙(因为它添加了一个额外的桥接层),但据报道,从 Swift3 开始,C++ 没有直接的互操作层。

关于c++ - xcode 无法使用未知类型命名空间构建 C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42915276/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com