[fpc-pascal] NULL pointer to array of integer
Vinzent Höfler
JeLlyFish.software at gmx.net
Wed Sep 13 19:38:51 CEST 2006
Marc Santhoff wrote:
> Am Mittwoch, den 13.09.2006, 14:00 +0200 schrieb Eduardo:
>> At 10:04 13/09/2006, you wrote:
>>> Hi,
>>>
>>> while fiddling with some C'isms I've stumbled over a function in a
>>> library expecting an array of integers *or* a NULL pointer.
>>>
>>> How can I hand over any NIL or 0 or something equal to NULL in C that is
>>> accepted by fpc?
By using a pointer to the array instead of an array. Was that too obvious?
>>> Using NIL or 0 does not work certainly...
>> I remember that on c a null pointer has value 0, but in ansi pascal
>> it has value 23. Don't know if it's still true or if fpc uses the c
>> value, or both.
This is nonsense. At least for the C version and I doubt that any Pascal
standard ever stated a value of "23" for NIL.
> ?
>
> Okay, I'll try that,
DON'T! The "right" way to do such nasty thing would be to dereference a
NIL pointer constant and then cast it to the according array type. Well,
I don't know if compiler checks already kick in at that point.
So you're better off with providing an overloaded version which accepts
a pointer instead of the array type.
Vinzent.
More information about the fpc-pascal
mailing list