Is there a way to use pre-compiled headers in VC++ without requiring stdafx.h?

后端 未结 9 772
予麋鹿
予麋鹿 2020-12-05 16:20

I\'ve got a bunch of legacy code that I need to write unit tests for. It uses pre-compiled headers everywhere so almost all .cpp files have a dependecy on stdafx.h which is

9条回答
  •  星月不相逢
    2020-12-05 17:02

    Pre-compiled headers are predicated on the idea that everything will include the same set of stuff. If you want to make use of pre-compiled headers then you have to live with the dependencies that this implies. It comes down to a trade-off of the dependencies vs the build speed. If you can build in a reasonable time with the pre-compiled headers turned off then by all means do it.

    Another thing to consider is that you can have one pch per library. So you may be able to split up your code into smaller libraries and have each of them have a tighter set of dependencies.

提交回复
热议问题