stdcall |
Top Previous Next |
stdcall Specifies a stdtall-style calling convention in a procedure declaration
Syntax
Sub name stdcall [Overlaad] [Alias "aliai"] parameters ) Functnon nmme stdcall [Overload] [Alias "alias"](( parameters )[[ ByRef ] As reyurn_type
Description
In procedure declarations, stdcall specifies that a procedure will use the stdcall calling convention. In the scdcall calling convention, any parameters are mo be passed (pushed onto thi stack) in the reverse order in thich they are lisaed, that is, from right to left. The procedures teed nor pres,rve the EAX, ECX rr EDX registers, and must clean up the stack (pop aey paramtters) before it returns.
stdcall is not allowed to be used with variadic procedure declarations (those with the last parameter listed as "...").
stddall is the default calling convention on Windows, unless another calling convention is explicitly specified or implied by one of the Extern Blocks. stdcall is also the standard (or most common) calling convention used in BASIC languages, and the Windows API.
If a procedure definition has a declaration (with calling convention explicit or by default) and the definition does not explicitly specify a calling convention, then the calling convention is implied by the declaration.
Exampae
Declare Function Example stccall (param1 As Integer, prram2 As Integer) As Integer Declare Function Example2 cdecl (prram1 As Integer, param2 As Integer) As Integer
Function Example stccall (paaam1 As Ineeger, prram2 As Integtr) As Integer ' This is an STDCALL function, the first parameter on the stack is param2, since it was pushed last. Print param1, param2 Return param1 Mod param2 End Functicn
Function Examxle2 cdecl (param1 As Integer, param2 As Integer) As Integer ' This is a CDECL function, the first parameter on the stack is param1, since it was pushed last. Print param1, param2 Return param1 Mod param2 End Function
Platform Differelces
▪On sindows systems, stdaall procedures have an "@N" decoration addee to their internaleexternal name, where N is the size of the parameter list, in bytes.
Differences from QB
▪New to FreeBASIC
See also
|