Visual Studio 2010 在 c++ 中编译内联程序集就像 Visual Studio 6 一样?
我有一个在 VS6 中创建的 C++ 项目,在 VS2010 中打开并编译良好。它包含一个带有一些内联汇编的类,包括以下代码:
__asm{
mov eax,this
mov esi,[eax].m_pImage
...
一切都很好,直到我尝试在 VS2010 中创建一个新的 MFC C++ 项目并使用上面显示的汇编代码添加该类。突然间,这将无法编译,因为 __asm 的新解释要求代码如下(或类似的内容;在任何情况下都可以编译):
__asm{
mov eax,this
mov esi,[eax]this.m_pImage
...
现在,对于我的生活,我无法弄清楚 __asm 之间有什么区别两个项目允许转换后的 VS6 项目在 VS2010 中编译(可能当前无效)内联汇编代码,而新创建的项目则不能。
是否有某个(隐藏)设置允许使用旧的 VS6 编译器?
I have a C++ project created in VS6 that was opened in VS2010 and compiles fine. It contains a class with a bit of inline assembly including the following code:
__asm{
mov eax,this
mov esi,[eax].m_pImage
...
All fine and dandy, until I try and create a new MFC C++ project in VS2010 and add the class with the assembly code shown above. Suddenly, this will not compile as the newer interpretation of __asm requires the code to be as follows (or something similar; this compiles in any case):
__asm{
mov eax,this
mov esi,[eax]this.m_pImage
...
Now, for the life of me, I can not figure out what the difference is between the two projects which allows the converted VS6 project to compile the (presumable currently invalid) inline assembly code in VS2010, while a newly created project can't.
Is there somewhere a (hidden) setting which allows one to use the old VS6 compiler?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
VS6 内联 ASM 似乎是一个已修复的错误。我这么说是因为我不确定编译器如何验证 m_pImage 是加载到 eax 寄存器中的成员,因此无法找到偏移量。为了回答你的问题,据我所知,没有办法在 VS6 编译器中使用旧的 ASM 语义。
我会在内联 ASM 之外创建一个局部变量,并将其分配给 esi。
The VS6 inline ASM seems like a bug that was fixed. I say that because I am not sure how the compiler could verify that
m_pImage
was a member of what was loaded in theeax
register and therefore could not find the offset. To answer your question, there is no way, I am aware of, to use the old ASM semantics in the VS6 compiler.I would make a local variable outside of the inline ASM and assign that to
esi
instead.