[fpc-devel] object as vararg

Jonas Maebe jonas.maebe at elis.ugent.be
Sat Mar 18 17:47:11 CET 2006


On 18 Mar 2006, at 16:46, Vincent Snijders wrote:

> The gtk2int.pas file of lazarus doesn't compile with fpc 2.1.1  
> (revision 2954) anymore.
>
> The error message is:
> gtk2int.pas(268,67) Error: Wrong type "TObject" in array constructor
>
> Line 268 looks like this:
>     gtk_list_store_set(FGtkListStore, @ListItem, [FColumnIndex+1,  
> AnObject, -1]);
>
> The declaration of gtk_list_store_set:
> procedure gtk_list_store_set(list_store:PGtkListStore;  
> iter:PGtkTreeIter); varargs; cdecl; external gtklib;
>
> I saw in the logs that there were some changes with varargs. Is  
> this a bug in the current compiler or should the lazarus code be  
> fixed?

I don't know, to be honest. C doesn't know objects, so you can't  
compare with that. C++ doesn't know Delphi-style objects either, its  
object model is more like TP's. And a pointer to a C++ or TP object  
is obviously just a pointer like any other, and you can pass pointers  
to varargs. It is trivial to add support for Delphi-style objects  
again (since converting those to a pointer is no problem).


Jonas



More information about the fpc-devel mailing list