cdecl
Specifies a cdecl-style calling convention in a procedure declaration
Syntax
`
Declare [Static] Sub procedure_name [Overload] cdecl [Alias "external_name"] [([parameter_list])] [Constructor [priority]] [Static] [Export]
Declare [Static] Function procedure_name [Overload] cdecl [Alias "external_name"] [([parameter_list])] As return_type [Static] [Export]
[Public|Private] Sub procedure_name [Overload] cdecl [Alias "external_name"] [([parameter_list])] [Constructor [priority]] [Static] [Export]
..procedure body..
End Sub
[Public|Private] Function procedure_name [Overload] cdecl [Alias "external_name"] [([parameter_list])] As return_type [Static] [Export]
..procedure body..
End Function
`
Description
In procedure declarations, `cdecl` specifies that a procedure will use the `cdecl` calling convention. In the `cdecl` calling convention, any parameters are to be passed (pushed onto the stack) in the reverse order in which they are listed, that is, from right to left. The procedures need not preserve the `EAX`, `ECX` or `EDX` registers, and must not clean up the stack (pop any parameters) before it returns - that is left to the calling code.
`cdecl` is the default calling convention for procedures declared within `Extern "C"` and `Extern "C++"` blocks. `cdecl` is also typically the default calling convention for many C compilers.
Example
`
' declaring 'strcpy' from the standard C library
Declare Function strcpy cdecl Alias "strcpy" (ByVal dest As ZString Ptr, ByVal src As ZString Ptr) As ZString Ptr
`
Differences from QB

- New to FreeBASIC

See also

- pascal, stdcall
- Declare
- Sub, Function