0

We are using Visual Studio 2013 at work and I have recently come across a problem I haven't seen before.

We have a project with some COM definitions in an _i.c file. The problem is when we added two configurations to the projects and solution, instead of these configurations being independent they seem to be tied, but only within the precompiled header settings which are meant to be overriding the project behaviour for this file.

Originally there were two configurations in the Project and Solution, which were Debug and Release.

These were MCBS builds. Recently we needed additional Unicode versions, so now there are 4 configurations Debug, Release, Debug-UNICODE, Release-UNICODE.

The global project setting for the C++ Precompiled Header files is "Use (/Yu)" this is true for both the original Debug and Release configuration (and now the new ones too)

Then the _i.c file has a specific setting of "Not Using Precompiled Headers" again this is true in the original Debug and Release configurations.

Now that we have added these other two configurations when you attempt to build them when the build gets to the _i.c file you either get told a) that the precompiled header file is from a previous version of the compiler, or b) that the compiler failed to find stdafx.h

However the file isn't supposed to be using the precompiled headers according to the project setting for this file (as presented by the IDE), yet it is attempting to do so.

Note worthy is the fact that when you change the files setting under the Release Configuration, you notice that the Release-UNICODE has now changed as well to the same setting (and vice versa). The same is true for Debug and Debug-UNICODE.

The [X]-UNICODE configurations where created as copies of the [X] configurations, but they aren't meant to be shared. All other settings other than precompiled headers do stay independent.

Also if you look at the saved project under the _i.c file it does not actually have all the configurations listed

<ItemGroup>
   ...
    <ClCompile Include="<filename>_i.c">
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-UNICODE|Win32'">NotUsing</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release-UNICODE|Win32'">NotUsing</PrecompiledHeader>
    </ClCompile>
   ...

If you ignore the IDE, the project is building correctly according to whats in the .vcxproj file, the trouble is the IDE fails to write it correctly

Peter Nimmo
  • 1,045
  • 2
  • 12
  • 25
  • The error message is not great, at issue is that the .pch file was generated by the C++ compiler but used by the C compiler. The project file shows the problem, you only got the setting correct for the Debug-UNICODE configuration. Be sure to use the upper-left combobox in the Project > Properties dialog to select Release-UNICODE first, then change the setting. – Hans Passant Aug 12 '16 at 13:25
  • Sorry, that isn't the correct contents. I had been fiddling with that file trying to find out what causes it. And so when I cut and pasted the text in it wasn't from the current repositories contents – Peter Nimmo Aug 12 '16 at 15:05
  • If I change the setting in the IDE for Debug-UNICODE the Debug version of that straight away matches what has just been set (in the IDE, but doesn't show up in the project file) – Peter Nimmo Aug 12 '16 at 15:07

0 Answers0