Connecting Tech Pros Worldwide Forums | Help | Site Map

VS .NET, violates listing order in "Additional Include Directories"

Arpi Jakab
Guest
 
Posts: n/a
#1: Nov 17 '05
I have a main project that depends on projects A and B. The main project's
additional include directories list is:

...\ProjectA\Dist\Include
...\ProjectB\Dist\Include

Each of the include directories contain a file named "cppfile1.h".

In my main project I #include "cppfile1.h". I rely on the order of paths in
additional include directories list to get file cppfile1.h from ProjectA and
not from ProjectB. Although this is not the case. The cppfile1.h from
ProjectB is compiled into the main project. I do not use precompiled headers
in the main project.

The source of the problem seem to be that the main project has a #include
for a file called "cppfile2.h" that is only located in ProjectB. Since this
file is #included into the main project before cppfile1.h, VS .NET seems to
grab all files from the ProjectB directory including the wrong version of
cppfile1.h. The ProjectB version of the cppfile1.h is used for all future
#includes, despite the order of directories in the "Additional Include
Directories" list.

I do not control code for projects A and B and hence cannot rename
cppfile1.h. Any help would be greatly appreciated.

- Arpi




Carl Daniel [VC++ MVP]
Guest
 
Posts: n/a
#2: Nov 17 '05

re: VS .NET, violates listing order in "Additional Include Directories"


Arpi Jakab wrote:[color=blue]
> I have a main project that depends on projects A and B. The main
> project's additional include directories list is:
>
> ..\ProjectA\Dist\Include
> ..\ProjectB\Dist\Include
>
> Each of the include directories contain a file named "cppfile1.h".
>
> In my main project I #include "cppfile1.h". I rely on the order of
> paths in additional include directories list to get file cppfile1.h
> from ProjectA and not from ProjectB. Although this is not the case.
> The cppfile1.h from ProjectB is compiled into the main project. I do
> not use precompiled headers in the main project.
>
> The source of the problem seem to be that the main project has a
> #include for a file called "cppfile2.h" that is only located in
> ProjectB. Since this file is #included into the main project before
> cppfile1.h, VS .NET seems to grab all files from the ProjectB
> directory including the wrong version of cppfile1.h. The ProjectB
> version of the cppfile1.h is used for all future #includes, despite
> the order of directories in the "Additional Include Directories" list.
>
> I do not control code for projects A and B and hence cannot rename
> cppfile1.h. Any help would be greatly appreciated.[/color]

Are you certain that the .cpp file in question doesn't have a file-specific
include path set for it? I'd recommend opening the .vcproj file in a text
editor and finding the .cpp file that's doing the #including to be sure.

Some projects converted from VC6 will erroneously have project settings
copied to file settings during the conversion. Changing the project setting
then has no effect on the file since the per-file settings take precedence.

-cd


Arpi Jakab
Guest
 
Posts: n/a
#3: Nov 17 '05

re: VS .NET, violates listing order in "Additional Include Directories"


The .cpp file in question does not further qualify the name of the header
file.

The .cpp file is "main.cpp", which includes "XXXProduct.ver". The .ver file
includes "cppfile1.h". Instead of getting it from include path
"..\BasicOuterLayer\Dist\Include" it gets it from "..\Share\Include".

Interestingly enough if I delete "cppfile1.h" from "..\Share\Include" the
project compiles with the correct version from
"..\BasicOuterLayer\Dist\Include". Also, once I have been able to build and
link successfully, I cannot reproduce the problem when the wrong version of
"cppfile1.h" is copied back to "..\Share\Include". Even if I do a rebuild on
the project. This issue has been reproduced in-house by other developers on
a different project.

The simplified .NET project file is:

<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="XXXProduct"
ProjectGUID="{3DF4856C-4223-4DD3-A93B-640C4525E02B}"
RootNamespace="XXXProduct"
SccProjectName=""
SccAuxPath=""
SccLocalPath=""
SccProvider="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="..\Dist\Exe"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="1">
<Tool
Name="VCCLCompilerTool"
Optimization="0"

AdditionalIncludeDirectories="..\Dist\Include;..\P roduct_2_SIL\Dist\Include;
...\BasicInnerLayer\Dist\Include;..\BasicOuterLaye r\Dist\Include;..\AlarmsEve
nts\Dist\Include;..\ConfigProxyStub\Dist\Include;. .\ComfigLibrary\Dist\Inclu
de;..\OuterLayerConfigProxyStub\Dist\Include;..\Ha rdwareKeyLicensing\Dist\In
clude;..\SoftwareKeyLicensing\Dist\Include;..\LogL ibrary\Dist\Include;..\Dat
aStormProduct_API\Dist\Include;..\DataStormProduct _Core\Dist\Include;..\Data
StormProduct_Client\Dist\Include;..\M3_Interfaces_ M3Common\Dist\Include;..\S
hare\Src;..\Share\Include"

PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;UNI CODE;_WIN32_WINNT=0x0400;_
CONSOLE;_USE_DEBUGLIB_FILE"
RuntimeLibrary="1"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/XXXProduct.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
BrowseInformation="1"
BrowseInformationFile=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/fixed:no"
AdditionalDependencies="version.lib Ws2_32.lib Netapi32.lib
MatDebug_dmtw.lib PXPIL_d.lib PXPIL_AE_mtd.lib PXPOLE_XXX_d.lib
PXPIL_Product_d.lib StaticLicense_d.lib dscore_d.lib dsapi_d.lib
DSClientLib_d.lib keylib_d.lib XMLConfigWrapper_d.lib M3Framework_d.lib
M3Common_d.lib"
OutputFile="..\Dist\Exe\XXXProduct_d.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"

AdditionalLibraryDirectories="..\Product_2_SIL\Dis t\Lib;..\BasicInnerLayer\D
ist\Lib;..\BasicOuterLayer\Dist\Lib;..\AlarmsEvent s\Dist\Lib;..\ComfigLibrar
y\Dist\Lib;..\ConfigProxyStub\Dist\Lib;..\DataStor mProduct_API\Dist\Lib;..\D
ataStormProduct_Core\Dist\Lib;..\DataStormProduct_ Client\Dist\Lib;..\Hardwar
eKeyLicensing\Dist\Lib;..\LogLibrary\Dist\Lib;..\M 3_PeerFramework\Dist\Lib;.
..\XXX_AE_1.0\Dist\Lib;..\XXX_DA_2.0\Dist\Lib;..\X XX_HDA_1.0\Dist\Lib;..\Oute
rLayerConfigProxyStub\Dist\Lib;..\SoftwareKeyLicen sing\Dist\Lib;..\Share\Lib
"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/XXXProduct_d.pdb"
GenerateMapFile="TRUE"
MapFileName=".\Debug/XXXProduct_d.map"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./XXXProduct.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="Incbuild XXXProduct.ver /rc=XXXProduct.rc"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"

AdditionalIncludeDirectories="..\Log\Dist\Include; ..\BasicInnerLayer\Dist\In
clude;..\XXXOuterLayer\Dist\Include;&quot;..\XXXOu terLayer\Etc\Comfig
Library\Dist\Include&quot;;&quot;..\XXXOuterLayer\ Etc\Outer Layer Config
Proxy
Stub\Dist\Include&quot;;..\Product_SIL\Dist\Includ e;..\Share\Include;&quot;$
(MTKCOMMON)\WinNT\Include&quot;"
ResourceOutputFileName="Debug/OxModicon.res"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<References>
</References>
<Files>
<File
RelativePath="Guids.h">
</File>
<File
RelativePath="icon1.ico">
</File>
<File
RelativePath="main.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="Main.h">
</File>
<File
RelativePath="XXXProduct.rc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="XXXProduct.ver">
</File>
<File
RelativePath="XXXProduct_version.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath=".\resource.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

Content of XXXProduct.ver:
----------------
"\n{"
/* components */
#include "cppfile1.h"
"\n}"
----------------
Any help is greatly appreciated.

- Arpi

"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam >
wrote in message news:ONfqqFuuEHA.944@TK2MSFTNGP11.phx.gbl...[color=blue]
> Arpi Jakab wrote:[color=green]
> > I have a main project that depends on projects A and B. The main
> > project's additional include directories list is:
> >
> > ..\ProjectA\Dist\Include
> > ..\ProjectB\Dist\Include
> >
> > Each of the include directories contain a file named "cppfile1.h".
> >
> > In my main project I #include "cppfile1.h". I rely on the order of
> > paths in additional include directories list to get file cppfile1.h
> > from ProjectA and not from ProjectB. Although this is not the case.
> > The cppfile1.h from ProjectB is compiled into the main project. I do
> > not use precompiled headers in the main project.
> >
> > The source of the problem seem to be that the main project has a
> > #include for a file called "cppfile2.h" that is only located in
> > ProjectB. Since this file is #included into the main project before
> > cppfile1.h, VS .NET seems to grab all files from the ProjectB
> > directory including the wrong version of cppfile1.h. The ProjectB
> > version of the cppfile1.h is used for all future #includes, despite
> > the order of directories in the "Additional Include Directories" list.
> >
> > I do not control code for projects A and B and hence cannot rename
> > cppfile1.h. Any help would be greatly appreciated.[/color]
>
> Are you certain that the .cpp file in question doesn't have a[/color]
file-specific[color=blue]
> include path set for it? I'd recommend opening the .vcproj file in a text
> editor and finding the .cpp file that's doing the #including to be sure.
>
> Some projects converted from VC6 will erroneously have project settings
> copied to file settings during the conversion. Changing the project[/color]
setting[color=blue]
> then has no effect on the file since the per-file settings take[/color]
precedence.[color=blue]
>
> -cd
>
>[/color]


Carl Daniel [VC++ MVP]
Guest
 
Posts: n/a
#4: Nov 17 '05

re: VS .NET, violates listing order in "Additional Include Directories"


Arpi Jakab wrote:[color=blue]
> The .cpp file in question does not further qualify the name of the
> header file.
>
> The .cpp file is "main.cpp", which includes "XXXProduct.ver". The[/color]

Where is Product.ver located? If it's in "..\Share\Include", then that's
your problem. The compiler always looks for a #included file in the
directory that contains the including file first (if it's a #include "file",
not a #include <file>, in which case the directory where the including file
was found is ignored).
[color=blue]
> .ver file includes "cppfile1.h". Instead of getting it from include
> path "..\BasicOuterLayer\Dist\Include" it gets it from
> "..\Share\Include".
>
> Also, once I have been able to
> build and link successfully, I cannot reproduce the problem when the
> wrong version of "cppfile1.h" is copied back to "..\Share\Include".[/color]

How a difference could survive a full rebuild is hard to envision.
Surviving a normal build is entirely possible, depending on usage of
precompiled headers.

-cd


Closed Thread


Similar .NET Framework bytes