whynot write code in stdafx.cpp?

  • Thread starter Thread starter Egbert Nierop \(MVP for IIS\)
  • Start date Start date
Egbert said:
Thanks in advance for answering this question.

Convention, pure and simple. There's really no reason to have a
stdafx.cpp - if there's a central source file that contains code that will
rarely change, there's nothing wrong with using that as the PCH builder.

The reason for the convention is just that - PCH building is expensive, and
typically you should only put things in your "stdafx.h" that rarely or never
change. Using a non-empty source file as the PCH builder means that you'll
rebuild the PCH file unnecessarily every time the code in that file changes
even if none of your #includes changed.

-cd
 
Carl Daniel said:
Convention, pure and simple. There's really no reason to have a
stdafx.cpp - if there's a central source file that contains code that will
rarely change, there's nothing wrong with using that as the PCH builder.

The reason for the convention is just that - PCH building is expensive, and
typically you should only put things in your "stdafx.h" that rarely or never
change. Using a non-empty source file as the PCH builder means that you'll
rebuild the PCH file unnecessarily every time the code in that file changes
even if none of your #includes changed.

-cd
 
Back
Top