Visual Studio 編譯選項

/guard:cf

參考:

Control Flow Guard

/OPT

鏈接優化選項。/OPT:REF 將剔除未使用的函數與變量,減小最終二進制文件的大小。 /OPT:ICF 對相同的 COMDAT 進行摺疊。 (Use ICF[=iterations] to perform identical COMDAT folding)

參考:

如何調試 Release 版本

要調試 Release 版本,需要指定以下選項:

  • C++ 中指定 Debug Information Format ,爲 Z7 或者 Zi (General -> Debug Information Format)
  • LINK 中指定 /DEBUG 選項。(Debugging -> Generate Debug Info)
  • LINK 中指定 /OPT:REF/OPT:ICF 選項。

參考:

如何使用本地運行時檢查

/RTC 選項可以執行運行時檢查。 /RTCc 當寬變量給窄變量賦值時,會報錯。 /RTCu 檢查使用未初化的變量。 /RTCs 檢查堆棧及數組越界問題。

參考:

LINK 的 BUG

/nologo 選項放在 /lib 選項之前,報錯。放在之後,就正常。

link /nologo /lib :ERROR
link /lib /nologo :OK

Visual Studio 圖形界面中設置 /MAP 選項,導致無法生成 Map 文件。 查看最後的項目屬性中,LINK 的 command line ,發現 /MAP 選項的冒號括到引號裏去了,導致該命令無效。解決辦法:只使用 /MAPINFO:EXPORTS 選項,不使用 /MAP 選項。

/MAP is useless
/MAPINFO:EXPORTS is ok

link map: can not find mz_os.obj ?

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章