exception on boost serialization
Hello, I can't resolve my exception when I compile my qt project with visual studio 2022. Error C2039 'throw_exception': is not a member of 'boost' DentalCad E:\boost_1_78_0\boost\serialization\throw_exception.hpp 30 I tried a compile a small example and work correctly without exception. I don't understand how solve the problem. Have you a suggest? Thanks in advance.
On 11/01/2022 10:22, Alessio Mochi via Boost-users wrote:
Hello, I can't resolve my exception when I compile my qt project with visual studio 2022.
Error C2039 'throw_exception': is not a member of 'boost' DentalCad E:\boost_1_78_0\boost\serialization\throw_exception.hpp 30
I tried a compile a small example and work correctly without exception. I don't understand how solve the problem. Have you a suggest?
That's the sort of error you normally get if you've included a header where the boost namespace is declared, but the header file where throw_exception is declared has not been included. Does Visual Studio have an include browser where you can see what the hierarchy of included headers are?
Yes, this is a piece of included hierarchy error is show. Thanks in advance 1>Note: including file: E:\DentalCad2.0-x64-vs2022\Common\Lib\vcglib\vcg\space\deprecated_point3.h 1>Note: including file: C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\assert.h 1>Note: including file: E:\boost_1_78_0\boost/archive/binary_iarchive.hpp 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\istream 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\ostream 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\ios 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xlocnum 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\streambuf 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xiosbase 1>Note: including file: C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\share.h 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\system_error 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\__msvc_system_error_abi.hpp 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\cerrno 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\stdexcept 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xcall_once.h 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xerrc.h 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\atomic 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xthreads.h 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xtimec.h 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\ctime 1>Note: including file: C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\time.h 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xlocale 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\memory 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xfacet 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xlocinfo 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\__msvc_xlocinfo_types.hpp 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\clocale 1>Note: including file: C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\locale.h 1>Note: including file: E:\boost_1_78_0\boost/archive/binary_iarchive_impl.hpp 1>Note: including file: E:\boost_1_78_0\boost/archive/basic_binary_iprimitive.hpp 1>Note: including file: E:\boost_1_78_0\boost/assert.hpp 1>Note: including file: C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\assert.h 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\locale 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xlocbuf 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xlocmes 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xlocmon 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\xloctime 1>Note: including file: E:\boost_1_78_0\boost/config.hpp 1>Note: including file: E:\boost_1_78_0\boost/config/user.hpp 1>Note: including file: E:\boost_1_78_0\boost/config/detail/select_compiler_config.hpp 1>Note: including file: E:\boost_1_78_0\boost/config/compiler/visualc.hpp 1>Note: including file: E:\boost_1_78_0\boost/config/pragma_message.hpp 1>Note: including file: E:\boost_1_78_0\boost/config/helper_macros.hpp 1>Note: including file: E:\boost_1_78_0\boost/config/detail/select_stdlib_config.hpp 1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\version 1>Note: including file: E:\boost_1_78_0\boost/config/stdlib/dinkumware.hpp 1>Note: including file: E:\boost_1_78_0\boost/config/detail/select_platform_config.hpp 1>Note: including file: E:\boost_1_78_0\boost/config/platform/win32.hpp 1>Note: including file: E:\boost_1_78_0\boost/config/detail/suffix.hpp 1>Note: including file: E:\boost_1_78_0\boost/config/detail/cxx_composite.hpp 1>Note: including file: E:\boost_1_78_0\boost/config/detail/cxx_composite.hpp 1>Note: including file: E:\boost_1_78_0\boost/cstdint.hpp 1>Note: including file: E:\boost_1_78_0\boost/serialization/throw_exception.hpp 1>E:\boost_1_78_0\boost/serialization/throw_exception.hpp(30,14): error C2039: 'throw_exception': is not a member of 'boost' 1>E:\boost_1_78_0\boost/serialization/throw_exception.hpp(24): message : see declaration of 'boost' Il giorno mar 11 gen 2022 alle ore 15:54 John McCabe via Boost-users < boost-users@lists.boost.org> ha scritto:
On 11/01/2022 10:22, Alessio Mochi via Boost-users wrote:
Hello, I can't resolve my exception when I compile my qt project with visual studio 2022.
Error C2039 'throw_exception': is not a member of 'boost' DentalCad E:\boost_1_78_0\boost\serialization\throw_exception.hpp 30
I tried a compile a small example and work correctly without exception. I don't understand how solve the problem. Have you a suggest?
That's the sort of error you normally get if you've included a header where the boost namespace is declared, but the header file where throw_exception is declared has not been included.
Does Visual Studio have an include browser where you can see what the hierarchy of included headers are?
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On 12/01/2022 10:22, Alessio Mochi wrote:
Yes, this is a piece of included hierarchy error is show. Thanks in advance [...] 1>Note: including file: E:\boost_1_78_0\boost/serialization/throw_exception.hpp 1>E:\boost_1_78_0\boost/serialization/throw_exception.hpp(30,14): error C2039: 'throw_exception': is not a member of 'boost' 1>E:\boost_1_78_0\boost/serialization/throw_exception.hpp(24): message : see declaration of 'boost'
That error at that site suggests that you are compiling with BOOST_NO_EXCEPTIONS defined, which in turn means that you need to define boost::throw_exception yourself before including any boost headers to define what you want to happen when an exception is "thrown" anyway. (Typically a call to abort(), possibly among other things.) Otherwise, you should remove BOOST_NO_EXCEPTIONS and allow it to throw normally. If you're not defining this explicitly in your preprocessor options, check if you have disabled exceptions in your compiler options. I'm not really familiar with Qt but google suggests that some older versions of it disable exceptions by default, but that newer versions might not. Perhaps you need to upgrade.
Hello Gavin,
I have not defined BOOST_NO_EXCEPTIONS.
I don't know why a small project with qt and boost serialization work and
this one no. I tried to add #include
On 12/01/2022 10:22, Alessio Mochi wrote:
Yes, this is a piece of included hierarchy error is show. Thanks in advance [...] 1>Note: including file: E:\boost_1_78_0\boost/serialization/throw_exception.hpp 1>E:\boost_1_78_0\boost/serialization/throw_exception.hpp(30,14): error C2039: 'throw_exception': is not a member of 'boost' 1>E:\boost_1_78_0\boost/serialization/throw_exception.hpp(24): message : see declaration of 'boost'
That error at that site suggests that you are compiling with BOOST_NO_EXCEPTIONS defined, which in turn means that you need to define boost::throw_exception yourself before including any boost headers to define what you want to happen when an exception is "thrown" anyway. (Typically a call to abort(), possibly among other things.)
Otherwise, you should remove BOOST_NO_EXCEPTIONS and allow it to throw normally.
If you're not defining this explicitly in your preprocessor options, check if you have disabled exceptions in your compiler options.
I'm not really familiar with Qt but google suggests that some older versions of it disable exceptions by default, but that newer versions might not. Perhaps you need to upgrade. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On 12/01/2022 09:04, Alessio Mochi via Boost-users wrote:
Hello Gavin, I have not defined BOOST_NO_EXCEPTIONS. I don't know why a small project with qt and boost serialization work and this one no. I tried to add #include
before include the serialization header, I don't know if it's correct but seem to fix the problem
What happens if at the very start of your cpp file you add:
#include
Il giorno mer 12 gen 2022 alle ore 00:44 Gavin Lambert via Boost-users
ha scritto: On 12/01/2022 10:22, Alessio Mochi wrote: > Yes, this is a piece of included hierarchy error is show. Thanks in advance [...] > 1>Note: including file: > E:\boost_1_78_0\boost/serialization/throw_exception.hpp > 1>E:\boost_1_78_0\boost/serialization/throw_exception.hpp(30,14): error > C2039: 'throw_exception': is not a member of 'boost' > 1>E:\boost_1_78_0\boost/serialization/throw_exception.hpp(24): message : > see declaration of 'boost'
That error at that site suggests that you are compiling with BOOST_NO_EXCEPTIONS defined, which in turn means that you need to define boost::throw_exception yourself before including any boost headers to define what you want to happen when an exception is "thrown" anyway. (Typically a call to abort(), possibly among other things.)
Otherwise, you should remove BOOST_NO_EXCEPTIONS and allow it to throw normally.
If you're not defining this explicitly in your preprocessor options, check if you have disabled exceptions in your compiler options.
I'm not really familiar with Qt but google suggests that some older versions of it disable exceptions by default, but that newer versions might not. Perhaps you need to upgrade. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
Hello John, I tried I get no error. Il giorno mer 12 gen 2022 alle ore 10:12 John Maddock via Boost-users < boost-users@lists.boost.org> ha scritto:
On 12/01/2022 09:04, Alessio Mochi via Boost-users wrote:
Hello Gavin, I have not defined BOOST_NO_EXCEPTIONS. I don't know why a small project with qt and boost serialization work and this one no. I tried to add #include
before include the serialization header, I don't know if it's correct but seem to fix the problem What happens if at the very start of your cpp file you add:
#include
#ifdef BOOST_NO_EXCEPTIONS
#error "Oooops"
#endf
Does the #error get hit?
Il giorno mer 12 gen 2022 alle ore 00:44 Gavin Lambert via Boost-users
ha scritto: On 12/01/2022 10:22, Alessio Mochi wrote: > Yes, this is a piece of included hierarchy error is show. Thanks in advance [...] > 1>Note: including file: > E:\boost_1_78_0\boost/serialization/throw_exception.hpp > 1>E:\boost_1_78_0\boost/serialization/throw_exception.hpp(30,14): error > C2039: 'throw_exception': is not a member of 'boost' > 1>E:\boost_1_78_0\boost/serialization/throw_exception.hpp(24): message : > see declaration of 'boost'
That error at that site suggests that you are compiling with BOOST_NO_EXCEPTIONS defined, which in turn means that you need to define boost::throw_exception yourself before including any boost headers to define what you want to happen when an exception is "thrown" anyway. (Typically a call to abort(), possibly among other things.)
Otherwise, you should remove BOOST_NO_EXCEPTIONS and allow it to throw normally.
If you're not defining this explicitly in your preprocessor options, check if you have disabled exceptions in your compiler options.
I'm not really familiar with Qt but google suggests that some older versions of it disable exceptions by default, but that newer versions might not. Perhaps you need to upgrade. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On 12/01/2022 09:04, Alessio Mochi via Boost-users wrote:
Hello Gavin, I have not defined BOOST_NO_EXCEPTIONS.
Interesting. The place where you're getting the compilation error is
within this section:
#ifndef BOOST_NO_EXCEPTIONS
#include <exception>
#endif
namespace boost {
namespace serialization {
#ifdef BOOST_NO_EXCEPTIONS
BOOST_NORETURN inline void throw_exception(std::exception const & e) {
::boost::throw_exception(e);
}
#else
template<class E> BOOST_NORETURN inline void throw_exception(E const
& e){
throw e;
}
#endif
} // namespace serialization
} // namespace boost
so BOOST_NO_EXCEPTIONS must be getting declared somewhere, which is
borne out by the include list you provided not showing "exception" in
there (at least, not that I can see).
There is a declaration of boost::throw_exception in
I don't know why a small project with qt and boost serialization work and this one no. I tried to add #include
before include the serialization header, I don't know if it's correct but seem to fix the problem
all.hpp is as here -
https://www.boost.org/doc/libs/1_78_0/boost/exception/all.hpp, which
includes
On 12/01/2022 09:04, Alessio Mochi via Boost-users wrote:
Hello Gavin, I have not defined BOOST_NO_EXCEPTIONS.
Ahhh, looks like our bug, I've just filed a PR to fix this here: https://github.com/boostorg/serialization/pull/250 The minimal header to #include prior to whatever serialization header you're using is boost/throw_exception.hpp BTW. Serialization should be doing that anyway but isn't :( The reason this hasn't been spotted until now, is that boost/throw_exception.hpp gets #included by very nearly everything in boost so it's an easy one to miss. HTH, John. -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
I don't understand why in another small project with qt and where I use boost serialization I get no exception without include boost/throw_exception.hpp Il giorno mer 12 gen 2022 alle ore 17:35 John Maddock via Boost-users < boost-users@lists.boost.org> ha scritto:
On 12/01/2022 09:04, Alessio Mochi via Boost-users wrote:
Hello Gavin, I have not defined BOOST_NO_EXCEPTIONS.
Ahhh, looks like our bug, I've just filed a PR to fix this here: https://github.com/boostorg/serialization/pull/250
The minimal header to #include prior to whatever serialization header you're using is boost/throw_exception.hpp BTW. Serialization should be doing that anyway but isn't :(
The reason this hasn't been spotted until now, is that boost/throw_exception.hpp gets #included by very nearly everything in boost so it's an easy one to miss.
HTH, John.
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On 14/01/2022 03:07, Alessio Mochi wrote:
I don't understand why in another small project with qt and where I use boost serialization I get no exception without include boost/throw_exception.hpp
Do the same trick to get the list of includes in the working project. See what's different between the two. Most likely, you're also including some other Boost header file that does include throw_exception.hpp, as John said before.
participants (4)
-
Alessio Mochi
-
Gavin Lambert
-
John Maddock
-
John McCabe