Is @"constantstring" pointer equal to @"constantstring" a guarantee?
Is @"constantstring" pointer equal to @"constantstring" a guarantee?
- Subject: Is @"constantstring" pointer equal to @"constantstring" a guarantee?
- From: Nathan Vander Wilt <email@hidden>
- Date: Thu, 27 Mar 2008 18:20:43 -0500 (CDT)
If I make two identical string constants
(@"samestring" and @"samestring") in my Cocoa program,
are their pointers guaranteed to be equal? I assumed
this without thinking while prototyping root objects
in an NSOutline view and it did work, however I just
realized that perhaps I shouldn't rely on this
behaviour.
The compiler documentation
(http://developer.apple.com/documentation/developertools/gcc-4.0.1/gcc/Constant-string-objects.html)
doesn't say either way. The CFString documentation
(http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFStrings/Articles/CreatingAndCopying.html)
says about the CFSTR() macro: "If there are two or
more exact instances of a constant string in an
executable, in some cases only one might be stored."
Which I'll take to mean that in some cases two or more
might be stored.
However, when I get to the documentation for the
@"..." construct
(http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/Articles/CreatingStrings.html)
it says "The compiler makes such object constants
unique on a per-module basis...".
So does that mean once I'm up at the Cocoa level, that
constant strings *are* guaranteed to have the same
pointer if their contents are the same? What is
"unique" and what is a "module" in this context?
thanks,
-natevw
____________________________________________________________________________________
¡Capacidad ilimitada de almacenamiento en tu correo!
No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:
http://correo.espanol.yahoo.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden