The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

    • RT @MarcBerns1: @zeeger Je zou wel gek zijn als je op erfpacht woont en in verduurzaming investeert: wordt meteen je erfpacht verhoogt, kan… 9 minutes ago
    • RT @isotopp: TIL my potato server at home can create a million directories on XFS in 16s, single threaded. Using multiprocessing(10), it t… 9 minutes ago
    • RT @hansdamen: Dat ging snel, het Twitteraccount @MinBijleveld is binnen de kortste keren omgezet in het generieke @DefensieMin. Gemakkelij… 10 minutes ago
    • RT @locuta: OPROEP AAN ALLEN: Kijk vanavond om 20:25 naar 'Alleen Tegen De Staat' op NPO2, documentaire over de Toeslagenaffaire. 11 minutes ago
    • RT @LarsWienand: Ein Kunde in einer Tankstelle gerät wegen der fehlenden Maske in Streit, kommt umgezogen und mit Maske wieder und erschieß… 12 minutes ago
  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,465 other followers

Class helpers and virtual methods – E2003 Undeclared identifier: ‘QueryInterface’/ ‘_AddRef’/’_Release’

Posted by jpluimers on 2018/06/20

Reminder to self: if you want to stay compatible with old (Pre Delphi XE) source code, then do not use virtual methods in class helpers.

Technically you can, as class helpers can inherit from other class helpers, but this is only supported as of Delphi XE.

In lower versions you get these errors as apparently the Delphi compiler tags an IInterface to the class helper compiler result:

[Error] Project1.dpr(14): E2003 Undeclared identifier: 'QueryInterface'
[Error] Project1.dpr(14): E2003 Undeclared identifier: '_AddRef'
[Error] Project1.dpr(14): E2003 Undeclared identifier: '_Release'

Source: [WayBackQualityCentral 9782

–jeroen

2 Responses to “Class helpers and virtual methods – E2003 Undeclared identifier: ‘QueryInterface’/ ‘_AddRef’/’_Release’”

  1. rvelthuis said

    Currently, a virtual call in a class helper is implemented through an interface (and has quite some overhead, as far as I can tell). I guess that was the intention in XE too, but it was not properly implemented.

    Due to the considerable overhead, even these days (Tokyo), it is not a good idea to add a virtual method through a class helper. It works, but tends to be slow. After all, the VMT of the class can’t be extended, so GetInterface must be called and the method is called on the interface.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: