Bernhard Tschirren wrote:
You cannot use SizeOf with objects?!?! It just does not work. It either aborts during compilation, or it returns rediculous values during execution.
Did you initialize the object with a constructor call?
BTW: There is a little difference to BP: In BP, objects that have neither constructors, destructors nor virtual methods don't have a VMT link. So it's possible in BP to get their size without initalizing them. I think that's kind of a misfeature, since the following program produces the wrong result for vy in BP, so IMHO, BP's behaviour should not be duplicated by gpc. (Though it's not 100% BP compatible then, a good BP program shouldn't make use of it, anyway.)
type x=object a:integer; end;
y=object(x) b:integer; end;
procedure w(var p:x); begin writeln(sizeof(p)) end;
var vx:x; vy:y;
begin w(vx); w(vy); end.