<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Am 15.08.2018 um 00:30 schrieb Benito
van der Zander:<br>
</div>
<blockquote type="cite"
cite="mid:209f4d11-4be1-f498-df58-fdd39574e49f@benibela.de">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div id="smartTemplate4-template">Hi,<br>
<br>
why is sizeof on object/class fields sometimes allowed and
sometimes not?<br>
<br>
type TTest = object<br>
f: integer;<br>
class procedure test;<br>
end;<br>
<br>
class procedure TTest.test;<br>
begin<br>
writeln(sizeof(f)); // does not compile<br>
writeln(sizeof(TTest.f)); // compiles<br>
end;<br>
<br>
---<br>
<br>
type TTest = class<br>
f: integer;<br>
class procedure test;<br>
end;<br>
<br>
class procedure TTest.test;<br>
begin<br>
writeln(sizeof(f)); // does not compile<br>
writeln(sizeof(TTest.f)); // does not compile<br>
end;<br>
<br>
surely that should all be equal to sizeof(integer)<br>
</div>
</blockquote>
Interestingly Delphi does not allow it either (though it fails with
two different errors for the two variants (note: I only tested the
class one)), so its behavior is the same as in FPC there. I
personally would say that it should be allowed however... *shrugs*<br>
<br>
Regards,<br>
Sven<br>
</body>
</html>