問題タブ [cdecl]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c - cdecl および pascal でパラメーターを渡すときの例外
エラー : :12: エラー: âfun1â の前に â=â、â,â、â;â、âasmâ、または â__attribute__â が必要です
assembly - 間接再帰を使用した _cdecl の問題
最終的な計算まで機能する階乗計算プログラムを作成しました。で階乗値を計算しているとき_multiply_fact
、ベース ポインタはランダムな値を指すことになります。私は何を間違っていますか?
通話中
手順
c++ - パラメータとして「異なる」呼び出し規約を使用して関数を渡す 64 ビット C++ であいまいなエラーが発生する
__cdecl
私の目標は、呼び出し規約と呼び出し規約の両方を使用して、任意の関数のプロトタイプを簡単に抽出すること__stdcall
です。32ビットで問題なく動作します。変更されている唯一のことは、テンプレート関数パラメーターの呼び出し規約です。
ウィキペディアによると:
Windows コンテキストで x64 アーキテクチャ用にコンパイルする場合 (Microsoft のツールを使用するか、Microsoft 以外のツールを使用するかに関係なく)、呼び出し規約は 1 つだけです。ここで説明するものであるため
stdcall
、thiscall
、cdecl
、fastcall
などはすべて同じものになります。
これにより、64 ビットのコードが壊れます。呼び出し規則は同じですが、関数をパラメーターとして渡すには、正しい命名法を使用する必要があります。IE で関数が として定義されている場合は__stdcall
、それを受け入れるラッパーに渡す必要があります__stdcall
。は同一ですが、を受け入れるラッパーに対して__cdecl
定義された関数を渡す必要があります。__cdecl
__cdecl
32 ビットで動作する例:
私の目標は、たとえば次のように実行できるようにすることでした。
これは 32 ビットでは問題ありません。ただし、 x64 では__stdcall
と__cdecl
は明らかに同一であるため、64 ビットでは機能せず、呼び出しが曖昧であるというエラーが発生します。また、テンプレートが既に定義されていることもわかります。直観的には、コンパイラはそれらを同一と見なすため、関数__cdecl
をこの関数に渡すことができるように思えます。__stdcall
ただし、これは機能しません。
エラー C2995 'WrapperFC<T,Args...> wrap(T (__cdecl *)(Args...))': 関数テンプレートは既に定義されています
それらの 1 つだけを保持する場合、これらの関数の両方を同時にラップすることはできません。
コンパイラがそれらを同じと見なす場合、異なる呼び出し規則を受け入れるために異なるテンプレートを用意する必要があるのはなぜですか? そして、私がそうすると、なぜそれは完全に壊れて、あいまいですでに定義されていると言うのですか?
TL;DR:
64 ビット アーキテクチャの呼び出し規約が同一である場合、ある呼び出し規約を別の呼び出し規約を期待する関数に渡すことができないのはなぜですか? どうすれば修正できますか?
c++ - cdecl の説明が必要です: 「配列 5」とは何ですか?
ここにアクセスしてください: http://cdecl.org/
入力:
出力:
arr を char の配列 5 へのポインターとして宣言する
「配列 5」とは何ですか? これは単に 5 つの要素を持つ配列を意味するのでしょうか?
gcc - CDECL 呼び出し規約では、スタックにプッシュした引数を再利用できますか?
GCCcdecl
呼び出し規則では、呼び出しが返された後、スタックにプッシュした引数が同じであることを信頼できますか? ASM と C が混在し、最適化 ( -O2
) が有効になっている場合でも?
windows - Need help understanding stack frame layout
While implementing a stack walker for a debugger I am working on I reached the point to extract the arguments to a function call and display them. To make it simple I started with the cdecl convention in pure 32-bit (both debugger and debuggee), and a function that takes 3 parameters. However, I cannot understand why the arguments in the stack trace are out of order compared to what cdecl defines (right-to-left, nothing in registers), despite trying to figure it out for a few days now.
Here is a representation of the function call I am trying to stack trace:
This is what the function (unsurprisingly) printed to the console:
This is the stack trace generated at the breakpoint (the debugger catches the breakpoint and there I try to walk the stack):
The code that's responsible for dumping the stack frames (implemented using the DIA SDK, though, I don't think that is relevant to my problem) looks like this:
I am compiling the test program without any optimization in vs2015 update 3.
I have validated that I am indeed compiling it as cdecl by looking in the pdb with the dia2dump
sample application.
I do not understand what is causing the stack to look like this, it doesn't match anything I learned, nor does it match the documentation provided by Microsoft.
I also checked google a whole lot (including osdev wiki pages, msdn blog posts, and so on), and checked my (by now probably outdated) books on 32-bit x86 assembly programming (that were released before 64-bit CPUs existed).
Thank you very much in advance for any explanations or links!
c - asmを使用して出力バッファへのポインタを取得する方法は?
私は asm で関数を書かなければならず、C でプロトタイプを持っています。
どこ:
in
: 受信データ バッファへのポインタout
: 送信データ バッファへのポインタn
: データ行列の量。
関数は何も返しませんが、結果データの配列を操作し、結果に応じて変更する必要があります。
私が理解しているように、cdecl スタックでは次のようになります。
asm で受信バッファーを使用する方法はわかりましたが、送信バッファーの新しいアドレスを返す方法がわかりesp+8
ません*out
。どうすればこの問題を管理できますか?