Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / November 2004

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Arpi Jakab - 25 Oct 2004 22:17 GMT
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] - 25 Oct 2004 23:24 GMT
> I have a main project that depends on projects A and B. The main
> project's additional include directories list is:
[quoted text clipped - 20 lines]
> I do not control code for projects A and B and hence cannot rename
> cppfile1.h. Any help would be greatly appreciated.

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 - 18 Nov 2004 23:48 GMT
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;..\Product_2_SIL\Dist\Include;
..\BasicInnerLayer\Dist\Include;..\BasicOuterLayer\Dist\Include;..\AlarmsEve
nts\Dist\Include;..\ConfigProxyStub\Dist\Include;..\ComfigLibrary\Dist\Inclu
de;..\OuterLayerConfigProxyStub\Dist\Include;..\HardwareKeyLicensing\Dist\In
clude;..\SoftwareKeyLicensing\Dist\Include;..\LogLibrary\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;UNICODE;_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\Dist\Lib;..\BasicInnerLayer\D
ist\Lib;..\BasicOuterLayer\Dist\Lib;..\AlarmsEvents\Dist\Lib;..\ComfigLibrar
y\Dist\Lib;..\ConfigProxyStub\Dist\Lib;..\DataStormProduct_API\Dist\Lib;..\D
ataStormProduct_Core\Dist\Lib;..\DataStormProduct_Client\Dist\Lib;..\Hardwar
eKeyLicensing\Dist\Lib;..\LogLibrary\Dist\Lib;..\M3_PeerFramework\Dist\Lib;.
.\XXX_AE_1.0\Dist\Lib;..\XXX_DA_2.0\Dist\Lib;..\XXX_HDA_1.0\Dist\Lib;..\Oute
rLayerConfigProxyStub\Dist\Lib;..\SoftwareKeyLicensing\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;..\XXXOuterLayer\Etc\Comfig
Library\Dist\Include&quot;;&quot;..\XXXOuterLayer\Etc\Outer Layer Config
Proxy
Stub\Dist\Include&quot;;..\Product_SIL\Dist\Include;..\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

> > I have a main project that depends on projects A and B. The main
> > project's additional include directories list is:
[quoted text clipped - 30 lines]
>
> -cd
Carl Daniel [VC++ MVP] - 24 Nov 2004 01:54 GMT
> 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

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).

> .ver file includes "cppfile1.h". Instead of getting it from include
> path "..\BasicOuterLayer\Dist\Include" it gets it from
[quoted text clipped - 3 lines]
> build and link successfully, I cannot reproduce the problem when the
> wrong version of "cppfile1.h" is copied back to "..\Share\Include".

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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.