[fpc-devel] StrPos giving a access violation
Jonas Maebe
jonas.maebe at elis.ugent.be
Mon Dec 12 13:45:36 CET 2005
On 12 dec 2005, at 13:30, Micha Nelissen wrote:
>> Taken from Delphi 7 help:
>> Mixing Delphi strings and null-terminated strings
>> * You can also use Pointer(S) to cast a long string to an untyped
>> pointer. But if S is empty, the typecast returns nil.
>> * PChar(S) always returns a pointer to a memory block; if S is
>> empty, a pointer to #0 is returned.
>
> Thanks, that is very ugly. That means that PChar(Pointer(MyStr)) is
> not the same as PChar(MyStr) which is not very pascalish IMHO, but ok.
It happens in more in Pascal. For example, single(longint_var) is
also not the same as single(pointer(longint_var)) (let's assume a
32bit system). In the former case, the longint is convert to a
floating point number with the same value. In the latter case, you
get a floating point number with the same bit pattern as that
original longint (which may be a valid or invalid floating point
number, and whose value is almost certainly different from the
longint's value, except in case of 0).
Jonas
More information about the fpc-devel
mailing list