Re: _iVar prefixes (was Re: Draggable buttons)
Re: _iVar prefixes (was Re: Draggable buttons)
- Subject: Re: _iVar prefixes (was Re: Draggable buttons)
- From: "Erik M. Buck" <email@hidden>
- Date: Mon, 4 Feb 2002 11:11:53 -0600
>
1: Where is this written down?
I don't know where in Apple's documentation. It was a prominent notice in
the Openstep days. I believe the Openstep specification even states this.
>
>
2: What happens if there is a collision?
If you are lucky, the compiler has enough information and will generate a
warning or error.
>
>
I inherit from some AppKit object and declare _foo.
>
>
Scenario 1:
>
>
That object already has it declared, so the compiler complains. I
>
fix my code, and everyone is happy.
The compiler would complain if Apple left the header file unmodified.
Sometimes Apple changes the header files that they publish to obfuscate
things. Unfortunately, the linker is not fooled and the names with which
the frameworks were compiled is stored in their binaries. This is not a
common or serious concern, but it happens.
>
>
Scenario 2:
>
>
That object doesn't declare _foo. Later I run my compiled app
>
against a new version of AppKit which does declare _foo. Aren't we
>
screwed anyway because the base object changed size breaking binary
>
compatibility? (I am not on my X machine at the moment so I can't
>
disassemble the code to see what happens, but it would make sense to
>
me that iVar accesses generate code equivalent to structure field
>
accesses.)
Apple has ways to avoid breaking binary compatibility. Apple/NeXT has also
been known to require that applications be recompiled to work on and benefit
from a new OS release. Binary compatibility is preserved by keeping the old
frameworks or old framework versions on the system, but only implementing
new features in the new frameworks or new versions. A recompile is needed
to use the new framework or new features. Anyway, code that used to compile
might not compile with the new frameworks or framework versions because
Apple added an instance variable. Apple has also been known to the
_reserved1.. style instance variable and rename them later. See your next
scenario.
>
>
Scenario 2b:
>
>
Some object used to have a var _bar, which they renamed _foo. Should
>
matter if the size stays the same, right?
>
This can and does happen.