stdafx.h: When do I need it?

后端 未结 6 706
不思量自难忘°
不思量自难忘° 2021-01-01 10:08

I see so much code including stdafx.h. Say, I do not want pre-compiled headers. And I will include all the required system headers myself m

6条回答
  •  独厮守ぢ
    2021-01-01 10:32

    I know this is an old thread, but I thought I'd pass my opinion to readers. I found this in 2017, so I'm sure I'm not the only one that will be here.

    There is an advantage to using pre-compiled headers, that may be overlooked by others because they have been using their practice for many years. The C++ standard has evolved greatly. Instead of including vector in 20 files that you might need and and or whatever, you use a PCH file and the compiler has to do less work, and that makes happy faces for everyone. Also you can put your common macros in there, such as VERIFY, and ASSERT and smart class objects. Don't put your class headers in there, it wouldn't make sense for that, rather the standard library or something you will need to use globally in a lot of places such as the macros I mentioned.

    basically realize this, by including the headers you need in every file you need, such as iostream, string, and vector, you are effectively compiling that every single time as an inline to the file. Include a "Pre Compiled" header, well just the name should ring a bell there.

提交回复
热议问题