pattakosn
pattakosn

Reputation: 395

what is the purpose of the stdafx.cpp file when using precompiled headers with MSVC?

I am well aware of the reasons/purpose of precompiled headers and according to the documentation it suffices to include it on the very first line of source files. I do not understand though why i often see the idiom of having a matching stdafx.cpp file which simply includes the stdafx.h file.

As far as i understand the stdafx.cpp is useles, so can someone explain to me what am i missing? Is it simply old habit? am i missing sth and it is actually needed for sth?

i have read MSVC documentation and i have search so and google but i did not find anything

Upvotes: 0

Views: 28

Answers (1)

MSalters
MSalters

Reputation: 180305

Check the /Yc and /Yu (Create and Use) flags. The name stdafx.cpp is not special, but that file and only that is compiled with /Yc (create) in your project. Creating the precompiled header is definitely necessary.

Upvotes: 1

Related Questions