未知类型名称“命名空间”Xcode Boost

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10877455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:29:10  来源:igfitidea点击:

Unknown type name 'namespace' Xcode Boost

xcodeboost

提问by setimouse

I want to use boost in my Xcode project.(Xcode version 4.3.2)

我想在我的 Xcode 项目中使用 boost。(Xcode 版本 4.3.2)

I had build the boost from the MacPorts, and made the environment variables set.

我已经从 MacPorts 构建了 boost,并设置了环境变量。

But when I build the prj, there was the error:

但是当我构建 prj 时,出现了错误:

Unknown type name 'namespace'

未知类型名称“命名空间”

and the error code below:

和下面的错误代码:

// This file is automatically generated. Do not edit.
// ['../../libs/compatibility/generate_cpp_c_headers.py']
// Wed Jul 23 12:11:19 2003 ('GMTST', 'GMTST')

#ifndef __CSTDDEF_HEADER
#define __CSTDDEF_HEADER

#include <stddef.h>

namespace std {
  using ::ptrdiff_t;
  using ::size_t;
}

#endif // CSTDDEF_HEADER

回答by Yana

the auto generated code is C++, not Objective-C. Objective-C compiler rejects the invalid keyword 'namespace'.

自动生成的代码是 C++,而不是 Objective-C。Objective-C 编译器拒绝无效关键字“命名空间”。

To make it work change you project settings as follows: - go to you Project Settings and choose the Target - select Build Settings -> Apple LLVM compiler X.X - Language -> Compile Sources As and set it to Objective-C++ which allows mixture of Objective-C and C++.

要使其工作,请按如下方式更改项目设置: - 转到项目设置并选择目标 - 选择构建设置 -> Apple LLVM 编译器 XX - 语言 -> 编译源为并将其设置为 Objective-C++,允许混合目标-C 和 C++。