question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrongly computed PCH header dir

See original GitHub issue

For directory structure

PROJECT_DIR/
    src/
        stdafx.cxx
        stdafx.h

and project file importing those properties

  <ItemGroup>
    <ClCompile Include="src\stdafx.cxx">
      <PrecompiledHeader>Create</PrecompiledHeader>
    </ClCompile>
    <ClCompile Include="src\*.cpp" />
    <ClCompile Include="src\*.c">
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
    </ClCompile>
    <ClInclude Include="src\*.hpp" />
    <ClInclude Include="src\*.h" />
  </ItemGroup>

running Tidy Code with Clang Power Tool 2.5.1 and VS2017 outputs

VERBOSE: PCH cpp name: src\stdafx.cxx
VERBOSE: PCH header name: stdafx.h
Join-Path : Cannot find path 'Disc:\...\PROJECT_DIR\stdafx.h' because it does not exist.
At C:\Users\...\VisualStudio\15.0_7afaccbd\Extensions\4zo3oigp.tpb\clang-build.ps1:524 char:25
+ ... ]] $paths = Join-Path -Path "$base" -ChildPath "$child" -Resolve -Err ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Disc:\...\PROJECT_DIR\stdafx.h:String) [Join-Path], ItemNotFoundExce 
   ption
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

which is wrong because file is at ‘Disc:.…\PROJECT_DIR\src\stdafx.h’

Any workarounds? <PrecompiledHeaderFile> property doesn’t accept path, only filename

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
hero101111commented, Jan 26, 2018

Hello,

We’ve investigated your latest sample project and found that there are issues when project source files / headers are specified in property sheets. At the moment our project data loader is unable to load them from propsheets. We are working on a project data loader fix regarding this.

We’ll inform you when the fix will be pushed. Stay posted.

Regards, Gabriel

2reactions
Gorafcommented, Jan 23, 2018

Scenario which fails: All projects have the same directories structure

PROJECT_DIR/
    project_file
    src/
        stdafx.cxx
        stdafx.h
        <source_files>

so in a project file they import mentioned before properties

  <ItemGroup>
    <ClCompile Include="src\stdafx.cxx">
      <PrecompiledHeader>Create</PrecompiledHeader>
    </ClCompile>
    <ClCompile Include="src\*.cpp" />
    <ClCompile Include="src\*.c">
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
    </ClCompile>
    <ClInclude Include="src\*.hpp" />
    <ClInclude Include="src\*.h" />
  </ItemGroup>

from a common properties sheet with an entry like <Import Project="common.props" /> And to that point fix to the script works.

Now, lets say some project has its own unique, internal library in its sources, so this project’s structure looks like

PROJECT_DIR/
    project_file
    src/
        stdafx.cxx
        stdafx.h
        <source_files>
        library/
            <library_source_files>

so it also needs additional include entries in its project file after imported common includes. Like that

  <Import Project="common.props" />
  <ItemGroup>
    <ClCompile Include="src\library\*.cpp">
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
    </ClCompile>
    <ClInclude Include="src\library\*.h" />
  </ItemGroup>

And in such case script fails.

sample project.zip

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I fix unexpected end of file error with pch.h
One option, if you are new to c++, is to just turn off pre-compiled headers in the project settings.
Read more >
Cannot include pre-compiled header in a different folder
Choose a pre-compiled header. 2. Make a folder and make a source file inside there. 3. Try to either: 1) #include "pch.h ...
Read more >
Faster builds with PCH suggestions from C++ Build Insights
A guide to using vcperf and the C++ Build Insights SDK for creating and optimizing precompiled headers for your C++ builds.
Read more >
Precompiled Header (PCH) issues and recommendations
Precompiled headers work great as a “set it and forget it” feature. They rarely need attention when upgrading compilers, for example. However, ...
Read more >
Incorrect path for precompiled headers in ` ...
Describe the bug The -include path for precompiled headers in compile_commands.json file does not include parent directories.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found