Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Catching C++ exceptions thrown from a framework




On Jul 14, 2006, at 5:14 PM, Eric Slosser wrote:

Sam, this is a semi-well-known problem.

GCC decides to give an exception to a handler when the typeinfo of the exception matches that of the handler (or is a sub-class). But the comparsion isn't based on the munged name of the symbol, it's based on the equality of a integer constant that's handled out by the linker.

So you need to export the typeinfo symbols representing the exceptions you care about from both the catcher and catchee.

The easiest way to see if this is your problem is to export all symbols, and don't strip any symbols, and see if the problem goes away.

Thanks! This information fixed the problem in my test project, and when I have a little more time to look into it, I'm hopeful that it will fix the problem in my main app as well.


In Xcode, the relevant setting seems to be "Symbols Hidden by Default" under Code Generation. If this is checked in the main application, then exceptions thrown from the framework are not caught successfully by the main application. Unchecking this setting fixes the problem.

It turns out that Apple has a discussion of this setting and its impact on their web site:

<http://developer.apple.com/documentation/DeveloperTools/Conceptual/ CppRuntimeEnv/Articles/SymbolVisibility.html>

I had understood that I needed the exception classes to be exported from the framework, but I had not realized that they needed to be exported from the main app as well.

I'll be reading that more carefully next week to better understand the consequences of unchecking this setting in Xcode. I suspect that I'll end up manually exporting the typeinfo for the exception classes, as you suggested.

Many thanks to you, Marshall, and the academy. ;)


--Stuart A. Malone Llamagraphics, Inc. Makers of Life Balance personal coaching software http://www.llamagraphics.com/


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden
References: 
 >Re: Catching C++ exceptions thrown from a framework (From: Eric Slosser <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.