__Thiscall
 
Specifies the Thiscall calling convention in a member procedure declaration

Syntax

Type typename
declare Sub name __Thiscall [Overload] [Alias "alias"] ( parameters )
declare Function name __Thiscall [Overload] [Alias "alias"] ( parameters ) [ ByRef ] As return_type
End Type

Description

In member procedure declarations, __Thiscall specifies that a procedure will use the Thiscall calling convention. In the Thiscall calling convention, the implicit and hidden This parameter is passed in the ECX register.

The Thiscall calling convention is for 32-bit x86 targets only and is only partially implemented. It should work when using -gen gcc backend, but as of fbc-1.08.0, it is not implemented for the -gen gas backed.

It is not needed for normal fbc usage, and would typically only be needed for linking to and using g++/c++ libraries.

Example

'' __thiscall only makes sense on windows 32-bit
#if defined(__FB_WIN32__) And Not defined(__FB_64BIT__)
    #define thiscall __Thiscall
#else
    #define thiscall
#endif

Extern "c++"
Type UDT
    value As Long
    '' fbc doesn't automatically add the __thiscall calling convention
    '' therefore, currently needs to be explicitly given where needed
    Declare Constructor thiscall ()
    Declare Destructor thiscall ()
    Declare Sub someproc thiscall ()
    '' etc
End Type
End Extern


Version

  • Since fbc 1.08.0

Differences from QB

  • New to FreeBASIC

See also