Visual studio 2012编译Tbb40关于std::Copy_exception的错误解决

本文解决了在使用Visual Studio 2012编译时出现的错误,即在tbb_exception.h文件中尝试使用std::copy_exception导致的错误。讨论了此方法是否属于std命名空间以及如何在不同版本的Visual Studio中进行解决。

问题:编译时出现错误:

d:\tbb40_20120613oss\include\tbb\tbb_exception.h(357) : error C2039: “copy_exception”: 不是“std”的成员
d:\tbb40_20120613oss\include\tbb\tbb_exception.h(357) : error C3861: “copy_exception”: 找不到标识符

 

搜索结果:http://software.intel.com/en-us/forums/showthread.php?t=105837

 

Visual Studio 2012

I'm trying out the release candidate of Visual Studio 2012. tbb_exception.h does not compile due to use of std::copy_exception(). I'm having a hard time finding any info on this method. Is it really part of the std namespace? Will VS2012 be supported soon?
Thanks,
Paul
 

Vladimir Polin (Intel)June 8, 2012 11:28 PM PDT
Rate
 
Visual Studio 2012

Hello, you are right, 
the issue is the same for clang ( http://software.intel.com/en-us/forums/showthread.php?t=102603&o=a&s=lr), C++x0 std::copy_exception was renamed to std::make_exception_ptr in final version of C++11 standard. So you need to either rename it in the header or define /DTBB_USE_CAPTURED_EXCEPTION=1 to not use exception_ptr like for old compilers.
We are working on how is better to support both cases at once (i.e. vs2010 and vs2012).
thanks for the report
--Vladimir
Update - details on the issue:
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#1130
 

Sergey KostrovJune 9, 2012 4:22 PM PDT
Rate
 
Visual Studio 2012

Quoting paul3579
I'm trying out the release candidate of Visual Studio 2012. tbb_exception.h does not compile due to use of std::copy_exception(). I'm having a hard time finding any info on this method. Is it really part of the std namespace?

I just done verifications with different versions/editions of  Visual Studio and MinGW. Here are results:

     - Visual Studio 2005 Professional Edition - 'copy_exception' is not supported

     - Visual Studio 2008 Express Edition - 'copy_exception' is not supported

     - Visual Studio 2010 Express Edition - 'copy_exception' is  supported in ' exception' header file

     - MinGW v3.4.2 - 'copy_exception' is not supported

I don't think that Microsoft will remove that support in Visual Studio 2012.
 

简单解决办法(可能不规范):

更改该.h中

tbb_exception_ptr ( const captured_exception& src ) : my_ptr(std::copy_exception(src)) {}

tbb_exception_ptr ( const captured_exception& src ) : my_ptr(NULL) {}

问题解决,但可能爆异常时有问题!

# ChildEBP RetAddr Args to Child 00 (Inline) -------- -------- -------- -------- dll_repair!ATL::ChTraitsCRT<wchar_t>::StringCompare+0x5 [c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\atlmfc\include\cstringt.h @ 564] 01 (Inline) -------- -------- -------- -------- dll_repair!ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >::Compare+0x9 [c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\atlmfc\include\cstringt.h @ 1446] 02 (Inline) -------- -------- -------- -------- dll_repair!ATL::operator<+0xe [c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\atlmfc\include\cstringt.h @ 2555] 03 1913f71c 61c5a6a6 0a082580 0b1b0718 6aa97f07 dll_repair!std::less<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > >::operator()+0x11 [c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\xstddef @ 141] 04 1913f764 61c5ca28 1913f794 21724f08 0b1b0718 dll_repair!std::_Tree<std::_Tmap_traits<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::vector<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::allocator<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > > >,std::less<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > >,std::allocator<std::pair<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > const ,std::vector<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::allocator<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > > > > >,0> >::_Insert_hint<std::pair<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > const ,std::vector<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::allocator<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > > > > &,std::_Tree_node<std::pair<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > const ,std::vector<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::allocator<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > > > >,void *> *>+0xf6 [c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\xtree @ 1686] 05 (Inline) -------- -------- -------- -------- dll_repair!std::_Tree<std::_Tmap_traits<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::vector<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::allocator<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > > >,std::less<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > >,std::allocator<std::pair<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > const ,std::vector<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::allocator<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > > > > >,0> >::emplace_hint+0x28 [c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\xtree @ 1163] 06 (Inline) -------- -------- -------- -------- dll_repair!std::map<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::vector<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::allocator<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > > >,std::less<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > >,std::allocator<std::pair<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > const ,std::vector<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::allocator<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > > > > > >::_Try_emplace+0x63 [c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\map @ 232] 07 (Inline) -------- -------- -------- -------- dll_repair!std::map<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::vector<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::allocator<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > > >,std::less<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > >,std::allocator<std::pair<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > const ,std::vector<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::allocator<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > > > > > >::try_emplace+0x63 [c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\map @ 248] 08 1913f78c 61c5d871 1913f8b8 1913f8a8 6aa970af dll_repair!std::map<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::vector<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::allocator<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > > >,std::less<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > >,std::allocator<std::pair<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > const ,std::vector<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >,std::allocator<ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > > > > > >::operator[]+0x68 [c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\map @ 363]
07-04
(gdb) bt #0 0x005cd5ff in std::_Rb_tree_decrement(std::_Rb_tree_node_base*) () from /usr/lib/libstdc++.so.6 #1 0x080e3b15 in std::_Rb_tree_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement> >::operator-- (this=0xbfbacdc4) at /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_tree.h:199 #2 0x080e3873 in std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement> > >::_M_insert_unique (this=0x89b53a0, __v=...) at /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_tree.h:1179 #3 0x080e31df in std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement> > >::_M_insert_unique_ (this=0x89b53a0, __position=..., __v=...) at /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_tree.h:1217 #4 0x080e2ee7 in std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, STDTM::AlarmElement, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement> > >::insert (this=0x89b53a0, __position=..., __x=...) at /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_map.h:540
06-13
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值