04-11-2023, 05:16 PM
Declare Library "plus"
Function calc_plus% (a As Integer, b As Integer)
End Declare
In the above, QB64 will attempt to pass the _OFFSETs of the two parameters for you, and I don't think that's what you're looking for. To pass the value of those Integers, use BYVAL as Jack as suggested above.
Declare Library "plus"
Function calc_plus% (BYVAL a As Integer, BYVAL b As Integer)
End Declare
Point 2 that you might try is to DECLARE DYNAMIC LIBRARY or DECLARE CUSTOMTYPE LIBRARY and see if that corrects the issue. You're trying to send and receive INTEGER values (16-bit) and the C-code you've written is actually looking to use 32-bit LONG values. DECLARE DYNAMIC and DECLARE CUSTOMTYPE aren't as particular about 100% type matching, so swapping to those might solve the issue for you. I'll test exactly what all is needed later, when I get back home from physical therapy and give you a 100% working example then.
Function calc_plus% (a As Integer, b As Integer)
End Declare
In the above, QB64 will attempt to pass the _OFFSETs of the two parameters for you, and I don't think that's what you're looking for. To pass the value of those Integers, use BYVAL as Jack as suggested above.
Declare Library "plus"
Function calc_plus% (BYVAL a As Integer, BYVAL b As Integer)
End Declare
Point 2 that you might try is to DECLARE DYNAMIC LIBRARY or DECLARE CUSTOMTYPE LIBRARY and see if that corrects the issue. You're trying to send and receive INTEGER values (16-bit) and the C-code you've written is actually looking to use 32-bit LONG values. DECLARE DYNAMIC and DECLARE CUSTOMTYPE aren't as particular about 100% type matching, so swapping to those might solve the issue for you. I'll test exactly what all is needed later, when I get back home from physical therapy and give you a 100% working example then.