【问题标题】:How to disable Boost Concept Check如何禁用 Boost 概念检查
【发布时间】:2012-12-18 10:26:57
【问题描述】:

为了在 Windows 下使用 Visual Studio 2008 编译 C++ Net Lib 项目,我需要禁用概念检查(请参阅此线程:https://groups.google.com/forum/#!msg/cpp-netlib/G-hM25EnCWA/gdsHBaVfmggJ

编译在 Release 中有效,但在 Debug 中无效(.cpp 编译失败)

我通过在包含客户端标头之前定义 NDEBUG 来管理标头的编译成功。但是,当链接器想要链接到 Boost.system 库的发布版本时,这会失败:而我正在使用调试。我收到此错误:

6>链接:致命错误 LNK1104:无法打开文件“libboost_system-vc90-mt-1_50.lib”

我想用 BOOST_SYSTEM_NO_LIB 防止这种情况,但它仍然想链接到发布版本(我的项目链接到 'libboost_system-vc90-mt-gd-1_50.lib'(调试库))

在包含标题之前是否有一个简单的宏要定义,它将禁用 Boost.ConceptCheck 的东西,就像它在 Release 构建中所做的那样?我没有在 Boost 文档中找到任何信息,在头文件本身中也没有。

非常感谢

盖坦

【问题讨论】:

    标签: c++ visual-studio-2008 boost cpp-netlib


    【解决方案1】:

    我会这样做:

    #include <boost/concept/assert.hpp>
    // redefine concept assert, suppress the warning etc.
    #undef BOOST_CONCEPT_ASSERT
    #define BOOST_CONCEPT_ASSERT(Model)
    #include <boost/concept_check.hpp>
    
    struct not_an_iterator
    {};
    
    
    int main()
    {
      BOOST_CONCEPT_ASSERT((InputIterator<not_an_iterator>));
      return 0;
    }
    

    这将使concept_assert 什么都不做,但我担心它不会发生 以防止您的链接器错误,这些错误看起来很晦涩。

    【讨论】:

    • 在重新定义之前我会#undef BOOST_CONCEPT_ASSERT
    • @JonathanWakely 谢谢,做出了改变。
    猜你喜欢
    • 1970-01-01
    • 2021-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-29
    • 2020-10-28
    相关资源
    最近更新 更多