Working with QT Development, invoking an external dynamic library. dll, which is always run after calling an interface function and then collapsing, prompting for a segment error. One-step debugging always has a variable was accidentally changed, took two days to solve with the help of colleagues.
Here's how: adding _stdcall when defining an interface function pointer, its flaw is that it can only run on Windows platforms, not across platforms
typedef _stdcall Int (*func_wtdev_axiscount) (int vehicleid);
Problem solving. Shame Ah, the road of learning is long.
__stdcallThe function that is modified by this keyword, whose arguments are passed from right to left through the stack (the front part of __fastcall is transmitted by Ecx,edx), the function call is cleaned up by the callee before it is returned.
Not all languages support _cdcel call rules, but all support _sdtcall call rules, if you use VC made a DLL, exported some functions, if you want this DLL can be called by other languages, VB. Dephi. PB.. You declare his calling convention as __stdcallwindows API are _stdcall call rules,
The function calling convention determines how a program implements a function call and how arguments are passed. In a single language program, the calling convention is almost always correct, because there is always a default convention for all modules and the header file is responsible for the consistency between the invocation and the callee. In a mixed language program, different languages cannot share the same header file. Errors resulting from the calling convention cannot be found at compile time until the program is implemented at runtime (run-time) to implement function calls and immediately causes the application to crash. Keywords Maintainer of stack parameter passing __cdecl Caller parameter Reverse orderinto the stack (right-> left) __stdcall the callee parameter is reversed into the stack (right-> left) __fastcall callee parameter First deposit register, then stack thiscall (not keyword) The callee parameter is in the stack, the this pointer is stored ecx in C + +, you can specify the calling convention with the keyword __stdcall when the function is declared or defined. __stdcall calling conventions are often used in Windows programs or API functions. In GUI programs, PASCAL, WINAPI, and CallbaCK is defined as __stdcall. The default calling convention for the C language is __cdecl. __stdcall The name modifier is to put the name symbol before the underscore (_), and then add "@" and the function parameter bytes (required stack space)