[fpc-devel] object as vararg

Vincent Snijders vsnijders at quicknet.nl
Sun Mar 19 14:54:52 CET 2006


Jonas Maebe wrote:
> 
> 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).

We added a pointer typecast to our call to gtk_list_store_set. This code 
compiles (didn't test running it). As far as I am concerned this is good 
enough, so no further need to change the compiler.

Vincent.



More information about the fpc-devel mailing list