What are the implications of using /Zi vs /Z7 for Visual Studio C++ projects?

前端 未结 5 1076
野性不改
野性不改 2020-12-23 20:21

Background

There are several different debug flags you can use with the Visual Studio C++ compiler. They are:

  • (none)
    • Creat
5条回答
  •  伪装坚强ぢ
    2020-12-23 21:00

    Another disadvantage of /Z7 is the big size of the object files. This has already been mentioned here, however this may escalate up to the point where the linker is unable to link the executable because it breaks the size limit of the linker or the PE format (it gives you linker error LNK1248). It seems Visual Studio or the PE format has a hard limit of 2GB (also on x64 machines). When building a debug version you may run into this limit. It appears this does not only affect the size of the final compiled executable, but also temporary data. Only Microsoft knows about the linker internals, but we ran into this problem here (though the executable was of course not 2gigs large, even in debug). The problem miraculously went away and never came back when we switched the project to /ZI.

提交回复
热议问题