- jorge gonzalez
- PowerBuilder
- Sunday, 15 October 2023 02:32 PM UTC
The error message:
error r0042
Error: specifield argument type differs from required argument type at runtime in dll <dll name>
(invalid stack pointer on return from function call) at line 20
in open event of object w_genapp1_sheet1.
Environment:
PB 2022 R2 (Build 2819)
Windows 11 running in Parallels on a Apple Mac M1 processor.
Visual studio 2022 (arm 64).
Note. I build the dll as an x86 application
Problem:
I finally narrowed the problem down to me passing any parameter from a simple PB local external function call:
function long rettext( int text) library "testdllforpb.dll" alias for "rettext"
To this simple c++ dll:
extern "C" __declspec(dllexport) int rettext(int text); // This comes from the header (h) file
// Here's the c++ dll code (cpp)
extern "C" int rettext(int text)
{
return 3;
}
// Local external PB call:
function long rettext( int text) library "testdllforpb.dll" alias for "rettext"
I've tried __stdcall in the dll and PB does not like that at all.
If I change the dll so it doesn't have any parameters it works in PB.
Note. I found this old article , which is the exact problem I am having:
"https://codeverge.com/forum/sybase.powerbuilder.general_calling-custom-c++-dll-s-in-power_1037457"
Unfortunately the links mentioned in the article no longer exist.
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.