When Exception handling disabled...

  • Thread starter Thread starter Ele
  • Start date Start date
E

Ele

When Exception handling disabled compiler still spits out "C++ exception
handler used." Why is that?

Why does it ask for "Specify /EHsc"?

Thanks!

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(1453)
: warning C4530: C++ exception handler used, but unwind semantics are not
enabled. Specify /EHsc

c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xstring(1444) : while compiling class-template member
function 'void
std::basic_string<_Elem,_Traits,_Ax>::_Copy(std::basic_string<_Elem,_Traits,
_Ax>::size_type,std::basic_string<_Elem,_Traits,_Ax>::size_type)'

with

[

_Elem=char,

_Traits=std::char_traits<char>,

_Ax=std::allocator<char>

]

c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\stdexcept(39) : see reference to class template
instantiation 'std::basic_string<_Elem,_Traits,_Ax>' being compiled

with

[

_Elem=char,

_Traits=std::char_traits<char>,

_Ax=std::allocator<char>

]
 
Ele said:
When Exception handling disabled compiler still spits out "C++
exception handler used." Why is that?

Why does it ask for "Specify /EHsc"?

It's telling you that you're trying to compile code that requires exception
handling with exception handling disabled. Either change the code (in this
case, it's the standard library, so you can't really do that), or enable
exception handling.

-cd
 
Carl Daniel said:
It's telling you that you're trying to compile code that requires exception
handling with exception handling disabled. Either change the code (in this
case, it's the standard library, so you can't really do that), or enable
exception handling.

-cd
Thanks Carl.

By specifying "/EHsc", the compile error gone. So, in this case, what
"/EHsc" switch does here to solve the problem? Is it enabling exception
handling? What if exception handling has to be disabled and we have to use
the standard library, what shall we do then?
 
Ele said:
By specifying "/EHsc", the compile error gone. So, in this case, what
"/EHsc" switch does here to solve the problem? Is it enabling
exception handling?
Yes.

What if exception handling has to be disabled and
we have to use the standard library, what shall we do then?

You cannot use the standard library without exceptions. You can, however,
use a library a lot like the standard library without exceptions. I believe
that Dinkumware's Unabridged Library (see
http://www.dinkumware.com/libdual_vc.html) can be used with exceptions
disabled.

-cd
 
Back
Top