【问题标题】:Compile issue when upgrading Platform Toolset from v120 to v142 (visualstudio 2019)将 Platform Toolset 从 v120 升级到 v142 时的编译问题(visualstudio 2019)
【发布时间】:2020-03-23 15:15:37
【问题描述】:

我有一个项目,我可以使用平台工具集 v120 在 VS2019 中毫无问题地编译。 我将项目重新定位为使用平台工具集 v142 和 WSDK 10。我收到以下与模板相关的编译错误。有什么想法是什么原因造成的吗?

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.25.28610\include\utility(573,1):错误 C2440:“=”:无法从“_Other”转换为“_Ty”

        with
        [
            _Other=int
        ]
        and
        [
            _Ty=std::_Container_proxy *
        ] (compiling source file RTPPacketSequencer.cpp)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.25.28610\include\utility(573,42): message : Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast (compiling source file RTPPacketSequencer.cpp)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.25.28610\include\deque(872): message : see reference to function template instantiation '_Ty *std::exchange<std::_Container_proxy*,int>(_Ty &,_Other &&) noexcept(false)' being compiled
        with
        [
            _Ty=std::_Container_proxy *,
            _Other=int
        ] (compiling source file RTPPacketSequencer.cpp)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.25.28610\include\deque(869): message : while compiling class template member function 'std::deque<T,std::allocator<T>>::~deque(void) noexcept'
        with
        [
            T=int
        ] (compiling source file RTPPacketSequencer.cpp)
D:\dev\_inc\lockqueue.h(46): message : see reference to function template instantiation 'std::deque<T,std::allocator<T>>::~deque(void) noexcept' being compiled
        with
        [
           T=int
        ] (compiling source file RTPPacketSequencer.cpp)
D:\dev\_inc\lockqueue.h(109): message : see reference to class template instantiation 'std::deque<T,std::allocator<T>>' being compiled
        with
        [
            T=int
        ] (compiling source file RTPPacketSequencer.cpp)
D:\dev\_inc\lockqueue.h(116): message : see reference to class template instantiation 'CLockQueueTX<T>' being compiled
        with
        [
            T=int
        ] (compiling source file RTPPacketSequencer.cpp)'''

【问题讨论】:

    标签: visual-studio-2019


    【解决方案1】:

    您可能在某处有一些代码重新定义了 MSVC 标头内部使用的宏。

    我在一个项目中遇到了类似的问题,当我在 C++98/C++03 模式下运行时,我试图在自己的头文件中提供 #define nullptr 0 兼容宏。确保我没有在 _MSC_VER 环境中定义它解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2016-10-09
      • 1970-01-01
      • 1970-01-01
      • 2021-03-13
      • 2020-03-04
      • 1970-01-01
      • 1970-01-01
      • 2018-06-03
      相关资源
      最近更新 更多