On 2 Apr 2005 at 15:01, Maurice Lombardi wrote:
[...]
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.
It is with the "move" call that I actually don't need the compiler complaining about dereferencing untyped pointers.
One option was to have "{$borland-pascal}" and such before the call, and then have "{$gnu-pascal}" afterwards to turn off the BP mode. However, this now breaks other things: e.g.,
function foo (const p; size : cardinal) : Integer; begin [...] inc (count); {$delphi} move (p, values^[count]^, size); { will now compile } {$gnu-pascal} result := count; end;
The assignment to "result" will no longer compile, whatever you pass at the command line, because under GPC 20050331, "{$gnu-pascal}" means that "result" is no longer predefined :-(
In the example above, "result" will be accepted if you pass "--implicit- result" to the compiler. It will however, only be accepted inside that function. It will be rejected in any other function that comes thereafter - e.g.,
function foo (const p; size : cardinal) : Integer; begin [...] inc (count); {$delphi} move (p, values^[count]^, size); { will now compile } {$gnu-pascal} result := count; { accepted } end;
function bar : integer; begin result := 0; (* not accepted because of the {$gnu-pascal} above *) end;
Let's just say that this new feature has made life more difficult for me, since before the 20050331 snapshot, {"$gnu-pascal}" meant "allow everything that GPC supports". Now, it seems to mean something different. I am not sure whether this is an unintended side effect, but it does look like it to me!
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.greatchief.plus.com/