vc 中内嵌汇编 怎样调用类的成员函数?
classx{inta;pbulic:f(intb){a=b;}}intfn(intn){returnn*n;}voidmain(){inta,b;__asm{push2...
class x
{
int a;
pbulic:
f(int b)
{
a=b;
}
}
int fn(int n)
{
return n*n;
}
void main()
{
int a,b;
__asm
{
push 2;
call fn; //编译通过 求一个数的平方
sub esp,4;
mov a,eax;
}
x c;
__asm
{
push 0;
lea ecx,c;
call x::f //这个地方就错误了 我该如何题名这个函数呢?
}
} 展开
{
int a;
pbulic:
f(int b)
{
a=b;
}
}
int fn(int n)
{
return n*n;
}
void main()
{
int a,b;
__asm
{
push 2;
call fn; //编译通过 求一个数的平方
sub esp,4;
mov a,eax;
}
x c;
__asm
{
push 0;
lea ecx,c;
call x::f //这个地方就错误了 我该如何题名这个函数呢?
}
} 展开
2个回答
展开全部
静态成员函数引用前面加::谁都知道,
关键是在VC里面,内嵌汇编的时候,不能引用成员函数,MSDN上面明确说明了
An __asm block can call only global C++ functions that are not overloaded. If you call an overloaded global C++ function or a C++ member function, the compiler issues an error.
You can also call any functions declared with extern "C" linkage. This allows an __asm block within a C++ program to call the C library functions, because all the standard header files declare the library functions to have extern "C" linkage.
懂了吗?其实我也今天才肯定 哈哈~~
上面的global C++ functions 其实就是指 一般的函数,即:非成员函数
关键是在VC里面,内嵌汇编的时候,不能引用成员函数,MSDN上面明确说明了
An __asm block can call only global C++ functions that are not overloaded. If you call an overloaded global C++ function or a C++ member function, the compiler issues an error.
You can also call any functions declared with extern "C" linkage. This allows an __asm block within a C++ program to call the C library functions, because all the standard header files declare the library functions to have extern "C" linkage.
懂了吗?其实我也今天才肯定 哈哈~~
上面的global C++ functions 其实就是指 一般的函数,即:非成员函数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询