Visual Studio 2019 - how to setup project with multiple precompiled headers

Viewed 448

I'm having troubles setting up a project with multiple precompiled headers. As far as I read I can have as many as I want as long as there is only 1 per compile unit. Consider following example of targeted hierarchy:

source
  precomp1.h
  precomp1.cpp (only includes precomp1.h)
  precomp2.h
  precomp2.cpp (only includes precomp2.h)
  main.cpp (includes precomp1.h)
  module1
    fileA.h
    fileA.cpp (includes precomp1.h)
  module2
    fileB.h
    fileB.cpp (includes precomp2.h)

I've setup precomp1&2.cpp as /Yc.

I've setup the project settings as:

PCH: /Yu
PCH File: precomp1.h;precomp2.h
PCH Output: $(IntDir)module1.pch;$(IntDir)module2.pch

Also added $(SolutionDir)\source as additional include, otherwise intellisense gets all weird.

When I try to compile something it gives me error:

"unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?"

Any poiners what I'm missing?

0 Answers
Related