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

varptr to structs returns bad pointer value


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

Attachment: OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


Follow-Ups:
Re: varptr to structs returns bad pointer valueJussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
Re: varptr to structs returns bad pointer valuevuott@xxxxxxxxxxxx