Assorted questions ...

Matthew Woehlke mw_triad at users.sourceforge.net
Tue Jun 19 02:54:05 UTC 2007


(Please don't top post)

Sandro Andrade wrote:
> After all things compiled successfully, I added a second private data 
> member
> in Lib1 (float y), recompiled the liblib1.so, and all thinks in my
> applications works fine !!! The added data member didn't break the binary
> compatibility !!!!!

Yes it did.

- MyApp, linked against MyLib-0.1, allocates a MyClass from MyLib.
- MyLib-0.2 adds a private data member.
- Joe User runs MyApp (not recompiled), dynamically linked to MyLib-0.2.
- MyClass tries to access the new data member.
- **BAD THINGS HAPPEN**.

Summary: don't do that.

Ah, wait... you added a member to a class that your test program doesn't 
allocate. *That* is OK, after all that's how d-ptrs work; you can make 
all the BIC's you want to *private* (technically: "or unused, but that's 
bad practice") classes.

> If I change the visibility of Lib1::doSomething() from public to private,
> the application keeps working and a visibility error occurs only if I
> recompile the application !!!

Don't rely on gcc's name mangling conventions. Also you just broke SC 
which is arguably worse.

> I'm using g++ v4 in a Debian-like Linux ! Why does BC remain working after
> the included data member ?

Because you weren't using the class that you changed.

-- 
Matthew
"Still the prettiest." -- Legolas
(as quoted in The Very Secret Diaries by Cassandra Claire)
http://www.ealasaid.com/misc/vsd/





More information about the KDevelop-devel mailing list