Skip navigation.
 
mlRe: Strategies to prevent class name clashes
FROM : Jens Alfke
DATE : Sat Feb 16 17:42:27 2008

On 15 Feb '08, at 3:42 AM, Arne Scheffler wrote:

> the toolkit in question is VSTGUI. It's a C++ cross-platform UI 
> library. It is statically linked into every plug-in. Mostly the 
> users of it won't use Objective-C by them self.
> The problem I did face was that I have an ivar which is a C++ class 
> of the lib. And when I used this ivar and the C++ object had a 
> different layout than at build time it crashed.


I'm confused — is this a problem of collisions between C++ classes or 
Obj-C classes?

If the C++ code is statically linked into each plugin, then it can't 
conflict between multiple plugins. Each one will be directly calling 
its own copy of the code, even if the C++ classnames and namespaces 
are the same.

Objective-C classes _will_ conflict between multiple plugins, if they 
have the same name. So what you have to do is make sure that every 
plugin that statically links shared Obj-C code renames the classes 
with unique prefixes. Basically, any time you write an Obj-C bundle or 
framework, all the classes in it need to have a unique prefix, whether 
or not you wrote those classes yourself.

It sounds like what's happening to you is that some of your classes 
load out of your bundle and some get loaded from another plugin, and 
these mismatched classes are passing C++ object pointers between 
themselves. So when code from one plugin allocates a C++ object (with 
one version of the C++ code), and then code from a different plugin 
receives a pointer to that object and tries to operate on it using a 
different version of the C++ code, you go boom.

But that's not a C++ specific problem. As soon as you have parts of 
different versions of a library loaded and calling into each other, 
there will be trouble. I've had this happen with Obj-C and pure C code 
as well. You have to uniquify your Obj-C class names to avoid this.

—Jens_______________________________________________

Cocoa-dev mailing list (<email_removed>)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>

This email sent to <email_removed>

Related mailsAuthorDate
mlStrategies to prevent class name clashes Arne Scheffler Feb 15, 10:09
mlRe: Strategies to prevent class name clashes Lieven Dekeyser Feb 15, 10:42
mlRe: Strategies to prevent class name clashes Arne Scheffler Feb 15, 11:22
mlRe: Strategies to prevent class name clashes Uli Kusterer Feb 15, 11:43
mlRe: Strategies to prevent class name clashes Arne Scheffler Feb 15, 12:42
mlRe: Strategies to prevent class name clashes Thomas Engelmeier Feb 15, 13:04
mlRe: Strategies to prevent class name clashes Arne Scheffler Feb 15, 13:35
mlRe: Strategies to prevent class name clashes Thomas Engelmeier Feb 15, 15:57
mlRe: Strategies to prevent class name clashes glenn andreas Feb 15, 16:13
mlRe: Strategies to prevent class name clashes Jonathon Mah Feb 15, 17:11
mlRe: Strategies to prevent class name clashes Bill Bumgarner Feb 15, 17:53
mlRe: Strategies to prevent class name clashes B.J. Buchalter Feb 15, 21:16
mlRe: Strategies to prevent class name clashes Arne Scheffler Feb 16, 09:18
mlRe: Strategies to prevent class name clashes Jens Alfke Feb 16, 17:42
mlRe: Strategies to prevent class name clashes Arne Scheffler Feb 16, 19:14
mlRe: Strategies to prevent class name clashes Bill Bumgarner Feb 16, 19:37
mlRe: Strategies to prevent class name clashes Chris Hanson Feb 17, 05:45