[squeak-dev] FFI | How to declare pointer to external structure in #fields?

Tobias Pape Das.Linux at gmx.de
Tue May 19 07:52:45 UTC 2020


> On 19.05.2020, at 08:46, Marcel Taeumel <marcel.taeumel at hpi.de> wrote:
> 
> Hi Levente.
> 
> >  Does MyStruct exist when you're writing this method?
> 
> Yes.
> 
> > If yes, is there a refence to that class in ExternalType's StructTypes class variable?
> 
> Yes.
> 
> **
> 
> The issue was that I wanted to make a pointer to the struct I am currently (re-)defining:
> 

> struct MyStruct {
>    MyStruct *foobar;
> };

If you have control over the source, try this:

typedef struct s_MyStruct MyStruct;
typedef MyStruct* pMyStruct;
struct s_MyStruct {
	pMyStruct *foobar;
};

-t


> 
> Works fine when pointing to other structs. Should code generation work for this case? :-)
> 
> Best,
> Marcel
>> Am 18.05.2020 21:28:49 schrieb Levente Uzonyi <leves at caesar.elte.hu>:
>> 
>> Hi Marcel,
>> 
>> On Mon, 18 May 2020, Marcel Taeumel wrote:
>> 
>> > Hi, there!
>> > 
>> > In the #fields method of a new ExternalStructure, how can I express a pointer to another external structure?
>> > 
>> > First, non-pointer works as expected:
>> > ^ #( (other MyStruct) )
>> > 
>> > Second, this just treats it as a void*, which returns a generic ExternalData:
>> > ^ #( (other 'MyStruct*') )
>> 
>> This is how it should be written. Does MyStruct exist when you're writing 
>> this method? If yes, is there a refence to that class in ExternalType's 
>> StructTypes class variable?
>> 
>> Levente
>> 
>> > 
>> > Third, this gives me a debugger:
>> > ^ #( (other MyStruct *) )
>> > 
>> > :-)
>> > 
>> > Best,
>> > Marcel
>> > 
>> >
>> 
> 




More information about the Squeak-dev mailing list