[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] gst_string_to_oop with local string

From: Roland Plüss
Subject: Re: [Help-smalltalk] gst_string_to_oop with local string
Date: Wed, 11 Nov 2009 23:31:27 +0100
User-agent: Thunderbird (X11/20091031)

> On 11/11/2009 08:13 PM, Roland Plüss wrote:
>> Another solution would be "sprintf(&buffer[0], ... )"
>> which is again valid since&buffer[0] is of type "char*".
> &buffer[0] is exactly the same as buffer... the equivalence between
> pointers and arrays is quite basic C and C++, try it. :-)
In fact not. Go compile the version with buffer only. I'm using 4.x type
compilers ( as maybe older ones are not strict enough as they should be
) and all versions I used so far bail out on this one. In all my code I
use therefore the proper casting as the other way of writing it is in
fact not correct. The reason is that "char*" tells the compiler that a
null terminated string is expected. buffer[50] on the other hand is a
fixed size string without null termination. It is therefore fully
correct to disallow a direct conversion of one to the other since this
conversion is highly likely to cause an error somewhere down the line (
missing null termination => segv ). It's anyways something one should
not grow accustomed to since it is a dangerous mangling ( I still have a
few places where I use this mangling... I know I'm a bad boy :P )

Yours sincerely
Plüss Roland

Leader and Head Programmer
- Game: Epsylon ( , )
- Game Engine: Drag(en)gine ( , )
- Normal Map Generator: DENormGen ( )

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]