[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: varptr to structs returns bad pointer value
[Thread Prev] | [Thread Next]
[Date Prev] | [Date Next]
- Subject: Re: varptr to structs returns bad pointer value
- From: vuott@xxxxxxxxxxxx
- Date: Fri, 28 Feb 2025 19:12:00 +0100 (CET)
- To: Brian G <brian@xxxxxxxxxxxxxxxx>
- Cc: GambasList <user@xxxxxxxxxxxxxxxxxxxxxx>
Hello, ...try: Private Extern myFunction(data As Pointer) In "mylib" Public Struct myStruct result As Long msg As String End Struct Private myData As Struct Mystruct Public Sub doit2() myFunction(VarPtr(myData)) End 27 feb 2025, 21:13 da brian@xxxxxxxxxxxxxxxx: > I am not sure if this is a bug or not > > When passing structures to external c functions varptr fails to produce the correct pointer... > to the data of the structure. I think maybe I don't understand the difference, but it would seem they should > produce the same result. > > extern myFunction(data as pointer) use "mylib" > public dataSet as pointer > public struct myStruct > result as long > msg as string > end struct > public mydata as mystruct > > this works as expected > > public sub doit() > dataSet = alloc(sizeof(mystruct)) > mydata = dataSet > myFunction(dataSet) ' this works > end sub > > this fails > > public sub doit2() > mydata = new myStruct > dataSet = varptr(myData) > myFunction(dataSet) ' this fails invalid pointer provided > end sub > > -- > ~~~~ Brian >
varptr to structs returns bad pointer value | Brian G <brian@xxxxxxxxxxxxxxxx> |