bcc icon indicating copy to clipboard operation
bcc copied to clipboard

VarPtr and Ptr-array issues

Open GWRon opened this issue 2 years ago • 2 comments

This compiles - while I forgot a "varptr"

Local value:Object = String(1.2345:Float)
Local q:Byte Ptr[10]
(Int Ptr q)[0] = value.ToString().ToFloat()

But with "compiles" I mean it generates invalid C code.

Added the varptr ... and the compiled thing segfaulted.. until I rewrote it partially:

Local value:Object = String(1.2345:Float)
Local q:Byte Ptr[10]
'segfault
'(Int Ptr (Varptr q[0]))[0] = value.ToString().ToFloat()
'works
Local qPtr:Byte Ptr = Varptr(q[0])
(Int Ptr qptr)[0] = value.ToString().ToFloat()

(yfyi it is extracted from reflection.mod - tried stuff because of invoke() failing with floats)

GWRon avatar Mar 13 '22 13:03 GWRon