The Wiert Corner – irregular stream of stuff

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

  • My badges

  • Twitter Updates

    • RT @NodeSpace: Due to IPv4 shortages and the world refusing to use IPv6, we’re moving all services to IPX/SPX. After all, 0BAD33CE:0003FE7C… 1 hour ago
    • RT @Visit_NL: We're proud to present the ultimate Dutch flower: the #FloresTouristia! See for yourself how our scientists have worked mirac… 1 hour ago
    • RT @HPN2_0: Yep. That sums it up quite nicely. 1 hour ago
    • RT @adestmusica: Presentatie nieuwe uniformen! 🤩💂 Zaterdag 15 april is “Adest-dag” want deze middag zal de Drum- en Showband hun nieuwe un… 3 hours ago
    • @matijn Het goede nieuws is een nieuw huis. Mooi hoor! 3 hours 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 4,182 other subscribers

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 )

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: