Using methods-always-virtual gives a problem for interface-only/implementation-only compiles.
With the example shown below, if you compile with
gpc -c peterQ.pas
all is well, but if you compile as gp often does, first with interface-only and then with implementation-only:
gpc -c --interface-only peterQ.pas gpc -c --implementation-only peterQ.pas
gpc thinks the object defined in the interface is not methods-always-virtual.
Note that using the command line switch --methods-always-virtual in both compiles makes no difference.
Thanks, Peter.
{$methods-always-virtual} unit peterQ;
interface
type MyObject = object procedure Destroy; end;
procedure Create;
implementation
procedure MyObject.Destroy; begin Dispose( self ); end;
procedure Create; var obj: MyObject; begin New(obj); obj.Destroy; end;
end.
zany:~/unix/c/testgpco% gpc -c peterQ.pas peterQ.pas:9: warning: object type has virtual method, but no constructor zany:~/unix/c/testgpco% gpc -c --interface-only peterQ.pas peterQ.pas:9: warning: object type has virtual method, but no constructor zany:~/unix/c/testgpco% gpc -c --implementation-only peterQ.pas peterQ.pas:9: warning: object type has virtual method, but no constructor peterQ.pas: In method `MyObject.Destroy': peterQ.pas:17: error: argument 1 to `Dispose' must be a pointer