cl.exe和ml.exe的问题 [英] a problem with cl.exe and ml.exe

查看:505
本文介绍了cl.exe和ml.exe的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用cl命令编译一个cpp文件:

  cl test.cpp //生成的test.exe可以工作well 

那么我用另一种方法:

  cl / Fa / c test.cpp //生成一个test.asm程序集文件
ml test.asm //有失败!

为什么?如何解决?



源代码:

  test.cpp 

#include< iostream>
using namespace std;
int main()
{
cout<<hello\\\
;
}

错误信息:



< blockquote>

组装:test.asm
test.asm(1669):致命错误A1010:不匹配的块嵌套



:? $?6U?$ char_trait
s @ D @ std @@@ std @@ YAAAV?$ basic_ostream @ DU?$ char_traits @ D @ std @@@ 0 @ AAV10 @ PBD @ Z







今天我在c中写另一个代码

  // test.cpp 
#include< stdio.h>
void main()
{
printf(hello);
}

然后我编译代码

  cl / Fa / c test.cpp 
ml test.asm // ok!

这可能与C和C ++有所不同。这让我困惑了几天。

解决方案

如何解决? >在生成异常处理代码时,编译器会生成无效的程序集列表。Microsoft Connect上存在一个错误: http://connect.microsoft.com/VisualStudio/feedback/details/556051/cl-facs-generates-bad-masm-for-c-exception-handlers



在回应这个错误时,有一个半心半意的我们会考虑修复这个以及一个免责声明,列出C生成的文件/ C ++编译器用于信息目的。



看起来你可能有一个脚本修复这个特殊的问题:




  • 切除后的 ENDP 语句$ x ENDS 语句




  • 粘贴到之前 _TEXT ENDS b
    $ b

    至少看起来像是在简单程序生成的asm文件中的模式 - 我不知道这个模式是否一般。不幸的是,应用此修复后,使用 fs 覆盖和一些未定义的符号会出现几个新问题。谁知道,当你尝试这个有更复杂的程序,你会遇到什么吗?


    I used cl command to compile a cpp file:

    cl test.cpp  //the generated  test.exe can work well
    

    then I used another way:

    cl /Fa /c test.cpp   //generate a test.asm assembly file
    ml test.asm   // there failed!!!
    

    why? How to solve it?

    source code:

    //:test.cpp 
    
     #include<iostream>
     using namespace std;
     int main()
      {
        cout<<"hello\n";
      }
    

    wrong information:

    Assembling: test.asm test.asm(1669) : fatal error A1010: unmatched block nesting

    : ??$?6U?$char_trait s@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z


    today I write another code in c

    //test.cpp
    #include<stdio.h>
    void main()
    {
      printf("hello");
    }
    

    then I compile the code

    cl /Fa /c test.cpp
    ml test.asm //ok!
    

    It may be the difference in C and C++. This confuses me a few days. :(

    how to solve it? please help me.

    解决方案

    The compiler produces an invalid assembly listing when exception handling code is produced. There's a bug open on Microsoft Connect: http://connect.microsoft.com/VisualStudio/feedback/details/556051/cl-facs-generates-bad-masm-for-c-exception-handlers

    In a response to the bug, there's a half-hearted "we will consider fixing this" along with a disclaimer that "listing files generated by the C/C++ compiler are for informational purposes".

    It looks like you might be able to have a "scriptable" fix for this particular problem:

    • cut the ENDP statement that follows a text$x ENDS statement,
    • paste it just before the previous _TEXT ENDS statement

    At least that looks to be the pattern in the asm file generated by your simple program - I don't know if that pattern would hold generally.

    Unfortunately, after applying this fix, several new problems crop up with instructions using fs overrides and a couple undefined symbols. Who knows what else you'd run into once you tried this with a more complex program?

    这篇关于cl.exe和ml.exe的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆