【问题标题】:how to force xcode to use the correct iostream header c++如何强制 xcode 使用正确的 iostream 标头 c++
【发布时间】:2012-01-27 04:55:37
【问题描述】:
xcode 4.2
os x 10.7

当我将包含设置为如下所示时:

#include <iostream>
#include <boost/thread.hpp>

我从位于 /opt/local/include/boost/tr1/tr1 的文件中收到以下错误

Lexical or Preprocessor Issue
'boost/tr1/detail/config_all.hpp' file not found

/opt/local/include/boost/tr1/tr1/iostream 文件的内容:

//  (C) Copyright John Maddock 2005.
//  Use, modification and distribution are subject to the
//  Boost Software License, Version 1.0. (See accompanying file
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
//  This file exists to prevent std lib headers from accidentally
//  including a TR1 extention header; we must suppress this otherwise
//  we can end up with cyclic dependencies with some std lib implementations.
//
#ifndef BOOST_TR1_iostream_INCLUDED
#  define BOOST_TR1_iostream_INCLUDED
#  ifndef BOOST_TR1_NO_RECURSION
#     define BOOST_TR1_NO_RECURSION
#     define BOOST_TR1_NO_iostream_RECURSION
#  endif
#  include <boost/tr1/detail/config_all.hpp>
#  if defined(BOOST_HAS_INCLUDE_NEXT) && !defined(BOOST_TR1_DISABLE_INCLUDE_NEXT)
#     include_next <iostream>
#  else
#     include BOOST_TR1_STD_HEADER(iostream)
#  endif
#  ifdef BOOST_TR1_NO_iostream_RECURSION
#     undef BOOST_TR1_NO_iostream_RECURSION
#     undef BOOST_TR1_NO_RECURSION
#  endif
#endif

我应该使用位于 /Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1/ 的 iostream 标头

您必须原谅我,因为我对 c++ 非常陌生,对 xcode 更陌生。预先感谢您的任何帮助。

【问题讨论】:

  • 您究竟做了什么来自定义包含路径,以便它首先在 /opt 中查找?
  • 如果我在 boost 之前启动了我的包含路径,它会抛出各种错误。也许我需要取消递归搜索......
  • 或者告诉它专门搜索我需要的 boost 的哪些部分,而不是所有的 boost。我只是担心如果我不包括所有的提升,它会破坏事情。我对此太陌生,无法确定。

标签: c++ xcode boost iostream


【解决方案1】:

绝对关闭递归搜索。如果不指定完整的提升路径,您永远不能包含提升标头。 Boost 的大部分内容都是最终将进入标准的功能的训练场,因此有大量的 Boost 标头与标准标头具有相同的名称。还有一堆 boost headers 与其他 boost headers 具有相同的名称。这会给你带来无尽的悲痛。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-16
    • 1970-01-01
    • 1970-01-01
    • 2021-01-28
    • 1970-01-01
    • 1970-01-01
    • 2012-03-23
    相关资源
    最近更新 更多