0

Is it possible to use VC (Preferably one of the latest versions) and using C++ exceptions, that are not implemented over SEH?

NOTE - I don't mean catching SEH exceptions using C++ catch clause (/Eha \ /Ehsc), I mean using C++ exceptions without having SEH exceptions flying around in the background.

user972014
  • 3,296
  • 6
  • 49
  • 89
  • 2
    I'm curious to know what your underlying goal is, and what you mean by "flying around." Structured exception handling might be complex, but it's not chaotic. – Rob Kennedy Nov 14 '14 at 21:06
  • Changing my answer, sec. This would be a matter of replacing that part of the runtime (_CxxThrowException et. al.). – defube Nov 14 '14 at 21:07

1 Answers1

0

By default, C++ exceptions are built on top of SEH.

It is possible to change this, but you'd have to re-write a large portion of the runtime, and implement the frame handling logic yourself (read as: lots of assembly).

Due to the dramatic differences between stack frame layouts in 32-bit and 64-bit builds (for x86), you would not be able to re-use very much code between them (64-bit EH also requires digging into another area of the PE image).

That said, unless really really need to, just make sure your code is as portable as possible by using exceptions as you would anywhere else. You can, for the most part, pretend SEH isn't even there.

defube
  • 2,395
  • 1
  • 22
  • 34
  • Agreed. SEH is just a private detail of how VC implements `try`/`catch` for C++ exceptions. Just ignore SEH, unless you actually need to handle an SEH exception directly, in which case you have to use `__try`/`__except` instead of `try`/`catch`. – Remy Lebeau Nov 14 '14 at 21:42