I finally found a combination that works fine... more or less. It compiles and runs fine on 64 bit mode,
but it compiles and crashes on 32bit (does everything except the final YAY):
'Generated with PluriBASIC 6.0.74371.0
$ filename "pointers.exe"
' Works fine for 64 bit... but 32 bit mode crashes.
uses rtl32
% GMEM_FIXED = &H0
% GMEM_ZEROINIT = &H40
% GMEM_NOT_BANKED = &H1000
TYPE POINTAPI
x AS INT
y AS INT
END TYPE
TYPE TAGCTLDATA
ncolor AS INT
scolor AS INT
hcolor AS INT
dcolor AS INT
nborder AS INT
lfescapement AS INT
pnormal AS INT
pselected AS INT
phover AS INT
pdisabled AS INT
hrgn AS INT
bhover AS INT
bcapture AS INT
bmousedown AS INT
bneedbitmaps AS INT
centerpoint AS POINTAPI
hbutton AS INT
idbutton AS INT
END TYPE
DECLARE FUNCTION GLOBALALLOC LIB "KERNEL32.DLL" ALIAS "GlobalAlloc" (BYVAL P1 AS INT, BYVAL P2 AS INT) AS LONG
Declare Function PluriBASICMessageBox Lib "user32.dll" Alias "MessageBoxA"
' STARTS STR$.BIN
' Enter the stock code and functions here.
FUNCTION _STR(double v, long d = 8) as string
long d2 = d-1
if v < 0 then
return str(v, d2)
else
return " " & str(v, d2)
end if
END FUNCTION
' END OF STR$.BIN
' STARTS SIZEOF.BIN
'not needed
' END OF SIZEOF.BIN
' STARTS PLURIBASIC_INIT.BIN
' Enter the stock code and functions here.
' END OF PLURIBASIC_INIT.BIN
' STARTS MSGBOX.BIN
FUNCTION MSGBOX(string sText, sys mOptions = 0, string sCaption = "PluriBASIC") AS LONG
FUNCTION = PluriBASICMessageBox(0, sText, sCaption, mOptions)
END FUNCTION
' END OF MSGBOX.BIN
' STARTS CALLBACKDATA.BIN
' END OF CALLBACKDATA.BIN
' Initializes various things in the script.
FUNCTION PluriBASIC_Initialize() AS LONG
END FUNCTION
FUNCTION MODUL(BYVAL TAGCTLDATA _ByValue_ptctldata, BYVAL INT _ByValue_ss) AS INT
INT _FUNCTION = 0
TAGCTLDATA ptctldata = _ByValue_ptctldata
INT ss = _ByValue_ss
MSGBOX "Consult: " & _STR(ptctldata.ncolor)
RETURN _FUNCTION
END FUNCTION
FUNCTION PBMAIN() AS INT
INT _FUNCTION = 0
CALL PluriBASIC_Initialize()
DIM ptctldata AS TAGCTLDATA PTR
@ptctldata = GLOBALALLOC(GMEM_FIXED OR GMEM_ZEROINIT, SIZEOF(TAGCTLDATA))
ptctldata.ncolor = 12345
ptctldata.centerpoint.x = 1
MODUL(ptctldata, ptctldata.ncolor)
MSGBOX "YAY: " & _STR(ptctldata.ncolor) & _STR(ptctldata.centerpoint.x) ' DOES NOT DISPLAY THIS ON 32 BIT MODE
END FUNCTION
PBMAIN() ' invoke entry point
Added:
When i pass ptctldata BYREF, PluriBASIC generates the following MODUL function, which doesnt crash at the end on 32 bit mode or 64 bit mode (Works fine on both):
FUNCTION MODUL(BYREF TAGCTLDATA ptctldata, BYVAL INT _ByValue_ss) AS INT
INT _FUNCTION = 0
INT ss = _ByValue_ss
MSGBOX "Consult: " & _STR(ptctldata.ncolor)
RETURN _FUNCTION
END FUNCTION
So, i am guessing the problem resides on either the parameter declaration or this line:
TAGCTLDATA ptctldata = _ByValue_ptctldata