Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-03

object as vararg

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Vincent Snijders

Hi,

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?

Vincent

Reply by email

Jonas Maebe
to Vincent Snijders
Vincent Snijders wrote 17 lines
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

Reply by email

Vincent Snijders
to Jonas Maebe
Jonas Maebe wrote 27 lines
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.

Reply by email

Jonas Maebe
to Vincent Snijders
Vincent Snijders wrote 10 lines
> 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).

The end result should be the same as it was in the past.

As far as I am concerned this is good enough, so no further need to change the compiler.

Ok.

Jonas

Reply by email