cl編譯控制台可調式的程式

來源:互聯網
上載者:User

元旦要調到新的組,開始系統的學習C++,首選的書籍是《C++ Primer》。系統的學習有個好處就是很系統,尤其是當自己寫過一段時間的代碼之後協助尤為明顯。

安裝了VS2008後,就可以在控制台下面編譯自己的代碼了首先執行檔案:
C:/Program Files/Microsoft Visual Studio 9.0/VC/vcvarsall.bat 
 

再執行如下命令,main.cpp是要編譯的檔案名稱:
cl /EHsc main.cpp 
 
即可以編譯產生exe檔案。如果想在VC2008中調試代碼的話,就是用一下的明令
cl main.cpp /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /W3 /nologo /ZI /TP /errorReport:prompt 

 

對應的選項協助如下:
cl /EHsc main.cpp 
/Od disable optimizations (default) 
/D<name>{=|#}<text> define macro 
/Gm[-] enable minimal rebuild 
/EHs enable C++ EH (no SEH exceptions) 
/EHc extern "C" defaults to nothrow 
/RTC1 Enable fast checks (/RTCsu) 
/MDd link with MSVCRTD.LIB debug lib 
/w<l><n> set warning level 1-4 for n 
/nologo suppress copyright message 
/Zi enable debugging information 
/Tp<source file> compile file as .cpp 
/errorReport:option Report internal compiler errors to Microsoft 
    none - do not send report 
    prompt - prompt to immediately send report 
    queue - at next admin logon, prompt to send report (default) 
    send - send report automatically 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.