gpt4 book ai didi

visual-c++ - 使用 MSVC _MANAGED (C++/CLI) 在非 C++03 模式下编译 Boost.Regex 1.76?

转载 作者:行者123 更新时间:2023-12-04 07:39:32 45 4
gpt4 key购买 nike

TL;博士
是否可以使用 C++/CLI 即 BOOST_REGEX_CXX03 在仅 header 模式(非 /clr 模式)下编译 Boost.Regex 1.76即 _MANAGED项目?

我们一直在使用Boost.Regex多年来在我们的常规 Visual C++ 项目中。我们的少数项目是用 Common Language Runtime Support (/clr) 编译的启用 C++/CLI ,(对于这些我们总是静态链接到 boost regex 库中)。我们总是预先构建 boost regex DLL 和静态库,然后从 MSVC 链接这些。
现在,with Boost 1.76 Boost.Regex 只是头文件,除非在 C++03 模式下编译。

( Version 1.76.0 ) ...

Regex:

  • Regex is now header only except in C++03 mode
  • Support for C++03 is now deprecated.
  • ...

然而,我们的 C++/CLI 项目将——通过 boost 配置魔法——自动选择在 C++03 == BOOST_REGEX_CXX03 中构建 Boost.Regex模式!
  • 我们当前的 MSVC 是 Visual Studio 19.7.6,_MSC_FULL_VER 192729112

  • 由于不再需要预先构建任何 Boost.Regex 二进制文件会非常方便,我们目前正在研究是否可以在 中编译 C++/CLI 项目。非 BOOST_REGEX_CXX03模式:
  • 有谁知道如何通过 boost/config 宏的魔力BOOST_REGEX_CXX03被选为 C++ _MANAGED项目? (我目前怀疑 _CPPLIB_VER ,但我什至不确定那是什么版本。)
  • 我们可以换这个吗? ->

  • 是否可以使用 C++/CLI 在仅 header 模式下编译 Boost.Regex 1.76,即 /clr_MANAGED项目?

    最佳答案

    快速回答问题:不可能在 C++11 模式下编译 Boost.Regex,即非 C++03 模式,/clr 标志打开。
    原因BOOST_REGEX_CXX03/clr 下被选中是boost\regex\config.hpp如果 ... BOOST_NO_CXX11_HDR_MUTEX ... BOOST_NO_CXX11_HDR_ATOMIC ... 中的任何一个,将选择它已设置,并且 这些设置在 /clr因为 C++/CLI 仅支持 C++03,或者更确切地说它支持所有 C++03 而例如std::mutex C++/CLI 不支持。
    others have written :

    It is not supported because the std::mutex implementation usesGetCurrentThreadId(). That's a winapi function that is not supposed tobe use in managed code since it might be running on a custom CLR hostthat doesn't use threads to implement threading.

    This is the good kind of problem to have, it shows that you arebuilding your code wrong. Your native C++ is being compiled with /clrin effect. Which works rather too well, all C++03 compliant code canbe compiled to MSIL ....


    所以,IFF 你需要 Boost.regex 在编译的翻译单元中 /clr ,必须使用C++03模式。
    至于 OP 问题:应该检查给定的使用 C++/CLI 的 VC++ 项目是否真的需要在/clr 上编译所有文件,或者实际上使用 Boost.Regex 的翻译单元无论如何都是本地 C++ 并且可以在没有/的情况下编译clr 然后只是与 C++/CLI 对象文件链接在一起。

    关于visual-c++ - 使用 MSVC _MANAGED (C++/CLI) 在非 C++03 模式下编译 Boost.Regex 1.76?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67566702/

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