When Exception handling disabled...

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>

]
 
C

Carl Daniel [VC++ MVP]

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
 
E

Ele

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?
 
C

Carl Daniel [VC++ MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top