Intuition tells me that CString is a 'C' string, as in the programming language 'C' (or a 'char *' if you want the C type definition). In C, these can be treated as either pointers or as character arrays (to cut a long story short). They are terminated with a \0 (if used correctly, that is: one of the "standard" buggy things to do in C is lose the terminating \0 which can cause all sorts of trouble. The Dest[size] := #0 example you gave is doing the "safe" thing of insisting that the string be terminated correctly.).
Its almost certainly compatible with Apple's CStringPtr = ^char ; as the point of these is C compatibility usually...
Usually characters are byte-sized in C. There are also wide characters, but that's another story again...
But we can want for Frank's definitive answer and the usual nitpicking of my sloppy answer :-|
Grant
At 6:32 AM +0000 29/4/03, Peter N Lewis wrote:
Could someone explain o me what CString is in the RTS?
It seems it is a pointer, and the docs somewhere describe it as ^Char, and it is generally used as a pointer, but some places it is used as an array, as in Dest[Size] := #0;
Since there seems good support for CString in string.pas, I'm trying to figure out if I can use it in the Mac Interfaces, if it is binary compatible with the Mac's definition of CStringPtr = ^Char;
BTW, I noticed in string.pas
if (s2 = nil) or (s2^ = #0)
I know GPC defaults to always doing short circuit, but would that be better written or_else?
Thanks, Peter.
-- http://www.interarchy.com/ http://documentation.interarchy.com/