我看到Doug Harrison对使用(即捕捉)结构化例外(见问题#3 )。但还有什么其他后果?例如,如果我有几个与/ EHA编译的项目会发生什么,与与/ EHS编译的其他项目混合?当库链接(编译时间或运行时)时是否存在问题?

但那只是一个例子。其他问题可能有什么?

有帮助吗?

解决方案

/EHa disables an optimization. With /EHs in effect, the compiler can omit exception filters if it can be sure that no C++ exception is ever thrown by the code wrapped in a try {}. That's a small space optimization on x86 and x64, very small time optimization on x86. Problem is, those filters are needed if you catch non-C++ exceptions. The consequence is that the stack gets unwound when such an exception is caught without the destructor of a C++ object getting called. Not good, /EHa avoids it.

Mixing doesn't cause linker problems. It causes the above problem.

Yes, /EHa also makes catch(...) do a very stupid thing, it really catches everything. That ship wreck sailed a while ago though, Pokemon C++ exception handling is a bad idea too.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top