FreeBASIC マニュアルのトップに戻る

FreeBASIC Thiscall

目次→命令文→手続き__THISCALL←オリジナル・サイト

__THISCALL 左にメニュー・フレームが表示されていない場合は、ここをクリックして下さい

←リンク元に戻る プログラム開発関連に戻る

メンバー手続き宣言で Thiscall 呼び出し規約を指定します。

構文:
declare Sub name __Thiscall [Overload] [Alias "alias"] ( parameters )
declare Function name __Thiscall [Overload] [Alias "alias"] ( parameters ) [ Byref ] as return_type

Sub name [__Thiscall] [Overload] [Alias "alias"] ( parameters )
Function name [__Thiscall] [Overload] [Alias "alias"] ( parameters ) [ Byref ] as return_type

記述:
Thiscall は、 x86 ターゲットの呼び出し規約で、最初の全体引数がスタックではなく ECX レジスタに渡されます。 他のすべての引数は右から左に渡され、呼び出し先はスタックをクリーンアップします (Stdcall と同様)。

win32 x86 では、mingw+gcc は、スタックにプッシュする代わりに、ECX レジスタによって非表示の This パラメータを渡すクラスの非静的メンバ手続きのデフォルトの呼び出し規約として Thiscall を使います。

非静的メンバー手続きの extern "c++" ブロック内の win32 x86 での既定の呼び出し規約は Thiscall です。

Thiscall は、通常の手続きと静的メンバー手続きに対して明示的に指定することで、既定の呼び出し規則を上書きできます。
他の呼び出し規則 (Cdecl/Stdcall/etc) を明示的に指定することで、非静的メンバー手続きの既定の Thiscall 呼び出し規則を上書きできます。

Thiscall は、宣言と定義の両方で指定できます。
手続き定義に宣言が (呼び出し規約が明示的またはデフォルトで)あり、その定義で呼び出し規約が明示的に指定されていない場合、呼び出し規約は宣言によって暗示されます。

例:
- extern "c++" 内および win32 / x86 上にあり、それが非静的メンバー手続きであり、他の呼び出し規則が指定されていない場合、デフォルトは __thiscall です:
Extern "c++"
    Type T extends object
        Declare Constructor() '' __thiscall is default
    End Type

    Constructor T()  '' __thiscall is default
    End Constructor
End Extern

- 定義が extern "c++" ブロックの外側にある場合、定義の __thiscall はオプションです (非静的メンバ手続きのデフォルトが __thiscall の場合):
Extern "c++"
    Type T extends object
        Declare Constructor() '' __thiscall is default
    End Type

End Extern

Constructor T() '' __thiscall is implied by declaration
End Constructor

旧例:
'' __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


バージョン: QBからの違い: 参照:
手続き に戻る
←リンク元に戻る プログラム開発関連に戻る
ページ歴史:2022-12-05 03:11:12
日本語翻訳:WATANABE Makoto、原文著作者:JeffMarshall

ホームページのトップに戻る

表示-非営利-継承