Prof A Olowofoyeku (The African Chief) a écrit:
On 31 Mar 2005 at 23:19, Markus Gerwinski wrote:
Prof A Olowofoyeku (The African Chief) wrote:
What I am trying to do is quite involved (part of a class library), and I need to use untyped pointers at the lower levels. I can always typecast, but would prefer not to.
Could you give us a code example here?
Here is a rough and ready example:
type listptr = pointer; pbuf = ^tbuf; tbuf = array [0..maxlist] of listptr;
type mylist = object values : pbuf; count : cardinal; constructor init (max : cardinal); procedure additem (const p; size : cardinal); virtual; [....] end;
[....]
procedure mylist.additem; begin [...] inc (count); move (p, values^[count]^, size); { gpc doesn't like this } end;
You could replace pointer by pByte. It shows you what size means, at least. This is not a solution for all, however. I had the same problem when writing also generic procedures for list manipulations. At some moment it is necessary to say what are the objects manipulated by the list. I found no way to avoid typecast at this moment. But for me this is an absolutely necessary condition to say where dereferencing leads to. Only generic list manipulations, input / output / move in memory can ignore that.
Maurice