[fpc-pascal] Using TInterfaceList and casting interfaces

Benito van der Zander benito at benibela.de
Sun Apr 7 15:33:43 CEST 2019


how should one use TInterfaceList with other interfaces than IUnknown? 
Let's say we have a ISomeInterface derived from IUnknown.

When we have an ISomeInterface, we can add it to the list fine, because 
an ISomeInterface is an IUnknown.

But when we get it back from the list, it is an IUnknown and not an 

Writing (list.get(0) as ISomeInterface), is very slow and not possible, 
when the interface has no GUID.

Writing ISomeInterface(list.get(0)) usually works fine, but when -CR is 
set, it does not compile.

Writing ISomeInterface(pointer(list.get(0))) appears to work, but is 
that safe, or does it confuse the reference counting?

Or perhaps it is better to use gvector rather than TInterfaceList?



More information about the fpc-pascal mailing list