Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using #include vs. ClInclude in vcxproj

Tags:

c++

msbuild

What's the purpose of defining a Cl task in msbuild like this?

  <ItemGroup>
    <ClInclude Include="Something.h" />
  </ItemGroup>

Is this necessary? It seems like just have #include "Something.h" in the source file should be sufficient. What purpose does the ClInclude task then fulfill?0

like image 286
Joe Avatar asked Sep 02 '25 09:09

Joe


1 Answers

It's basically just for use in the Visual Studio user interface: if you view projects in Solution Explorer and 'Show All Files' is turned off, it shows only what is defined in the different Items which serve as input for the build (ClInclude/ClCompile/Resource/...). So even when the compiler happily finds the include file, the IDE won't list it in Solution Explorer. Also functions like 'Go To Files' won't consider the file.

With 'Show All Files' turned on you get to see the whole directory structure, usually a better experience in my opinion, though it still shows files which aren't listed in the project explicitly with a red sign to incidate that. But then at least you can right-click on them and choose 'Include in Project' instead of finding them manually.

like image 135
stijn Avatar answered Sep 04 '25 22:09

stijn