- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我需要知道,当调用 C++ 中的类方法时,隐式“this”指针是第一个参数还是最后一个参数。即:它是先入栈还是最后入栈。
换句话说,我是在询问一个被调用的类方法是否被编译器认为是:
int foo::bar(foo *const this, int arg1, int arg2);
//or:
int foo::bar(int arg1, int arg2, foo *const this);
因此,通过扩展,更重要的是,这也将回答 G++ 是将 this 指针分别压入最后还是最先。我查询了谷歌,但没有找到太多。
另外,当调用 C++ 函数时,它们是否与 C 函数执行相同的操作?即:
push ebp
mov ebp, esp
总而言之:被调用的类方法看起来像这样吗?
; About to call foo::bar.
push dword 0xDEADBEEF
push dword 0x2BADBABE
push dword 0x2454ABCD ; This one is the this ptr for the example.
; this code example would match up if the this ptr is the first argument.
call _ZN3foo3barEpjj
谢谢,非常感谢。
编辑:为了澄清问题,我使用的是 GCC/G++ 4.3
最佳答案
这取决于您的编译器的调用约定和目标架构。
默认情况下,Visual C++ 不会将其压入堆栈。对于 x86,编译器将默认使用“thiscall”调用约定并将其传递到 ecx 寄存器中。如果为成员函数指定 __stdcall,它将作为第一个参数压入堆栈。
对于 VC++ 上的 x64,前四个参数在寄存器中传递。这是第一个参数,传入rcx寄存器。
关于c++ - C++ 隐含了这个,以及它是如何被压入堆栈的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1297205/
我正在使用 Fortran90,但我对它不太熟悉。 在代码的某些地方,我想在 t0 和 tf 之间创建一个由 n 个线性等距点组成的数组,所以我尝试了以下方法: t = t0+(/(i,i=0,n-1
我试图弄清楚为什么在数组构造函数内的 do 构造之前放置标量会产生它所得到的答案。 我一般理解 do 结构,(/(i,i=1,5)/) 相当于 (/1,2,3,4,5/)。 real, dimensi
我目前遇到的情况是,我需要能够通过应用程序 B 的隐式 Intent 广播来启动应用程序 A。应用程序之间没有数据传递。应用程序 A 被简单地启动,显示特定的 Activity。 我的问题是这样的;从
我是一名优秀的程序员,十分优秀!