[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: varptr to structs returns bad pointer value


In my opinion, Jussi, in these cases the best solution is the one you proposed:

https://lists.gambas-basic.org/archive/user/2025-02/0000234.html






4 mar 2025, 01:20 da jussi.lahtinen@xxxxxxxxx:

>> VarPtr() tries to return the memory address of where the value of a 
>>  variable is stored.
>>  
>>  So when you write:
>>  
>>  dataSet = varptr(myData)
>>  
>>  you get the the address of where the value of 'mydata' is stored, not 
>>  the address of the 'new MyStruct' object or the address of its contents.
>>  
>>  To get the address of a Gambas object contents, you must use the 
>>  'Object.Data()' static method on the object reference.
>>  
>>  dataSet = Object.Data(myData)
>>
>
> But if it is set "myData = New Struct", then will Gambas return an address to something that works like structure in C or Gambas object that works differently..?
> IE is the pointer usable for external library anyway?
>
> Jussi
>  
>


Follow-Ups:
Re: varptr to structs returns bad pointer valueJussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
References:
Re: varptr to structs returns bad pointer valueBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: varptr to structs returns bad pointer valueJussi Lahtinen <jussi.lahtinen@xxxxxxxxx>