Benito van der Zander
2018-08-14 22:30:35 UTC
Hi,
why is sizeof on object/class fields sometimes allowed and sometimes not?
type TTest = object
 f: integer;
 class procedure test;
end;
class procedure TTest.test;
begin
 writeln(sizeof(f));            // does not compile
 writeln(sizeof(TTest.f)); // compiles
end;
---
type TTest = class
 f: integer;
 class procedure test;
end;
class procedure TTest.test;
begin
 writeln(sizeof(f));            // does not compile
 writeln(sizeof(TTest.f)); // does not compile
end;
surely that should all be equal to sizeof(integer)
Bye,
Benito
why is sizeof on object/class fields sometimes allowed and sometimes not?
type TTest = object
 f: integer;
 class procedure test;
end;
class procedure TTest.test;
begin
 writeln(sizeof(f));            // does not compile
 writeln(sizeof(TTest.f)); // compiles
end;
---
type TTest = class
 f: integer;
 class procedure test;
end;
class procedure TTest.test;
begin
 writeln(sizeof(f));            // does not compile
 writeln(sizeof(TTest.f)); // does not compile
end;
surely that should all be equal to sizeof(integer)
Bye,
Benito