Include File Search Order 
Author Message
 Include File Search Order

Hello,

I'm using Visual C++ 6.0 and I'm having a problem with the compiler
picking up the wrong version of an include.

Example.

Directory1                Directory2
File1.c                      File2.c    <------Checked out Version of
Source
File1.h                      File1.h     <-----Checked out Version of
Source

My problem is that I tell Visual C++ to use File1.c from Directory1, and
File2.c from Directory2.  Both File1.c and File2.c include File1.h.
When compiling File1.c I would like Visual C++ to use the File1.h from
Directory2.  Directory2 contains a "checked out edited version of the
files".

It appears that Visuall C++ first looks for includes in the directories
where it finds the source.  I have included ( \I Directory2) option in
the project settings and from the help it appears this would not work,
nor did it.  I tried adding File1.h from Directory2 into the project,
(so it appeared under the Header Files folder in the Files View), and
that didn't work either.

There must be a way! Can someone help?  Thanks much in advance.

Dean



Mon, 27 Aug 2001 03:00:00 GMT  
 Include File Search Order
[...]

Quote:
> My problem is that I tell Visual C++ to use File1.c from Directory1, and
> File2.c from Directory2.  Both File1.c and File2.c include File1.h.
> When compiling File1.c I would like Visual C++ to use the File1.h from
> Directory2.  Directory2 contains a "checked out edited version of the
> files".

> It appears that Visuall C++ first looks for includes in the directories
> where it finds the source.  I have included ( \I Directory2) option in
> the project settings and from the help it appears this would not work,
> nor did it.  I tried adding File1.h from Directory2 into the project,
> (so it appeared under the Header Files folder in the Files View), and
> that didn't work either.

#include "File1.h" <-- Always looks in the local directory first
#include <File1.h> <-- Uses the includes from Tools | Options |
Directories and the local Project Settings

/Jonas U

--
Jonas Utterstr?m
Umetri AB, Box 7960, SE-907 19 Ume?, Sweden
Phone:  +46 90 154846
Fax:    +46 90 197685

Visit http://www.umetri.se



Tue, 28 Aug 2001 03:00:00 GMT  
 Include File Search Order
Quote:
>My problem is that I tell Visual C++ to use File1.c from Directory1, and
>File2.c from Directory2.  Both File1.c and File2.c include File1.h.
>When compiling File1.c I would like Visual C++ to use the File1.h from
>Directory2.  Directory2 contains a "checked out edited version of the
>files".

Why don't you explicitly tell VC where to look? Like

#include ".\Directory1\Header1.h"

Or even

#include "C:\My Projects\Project1\Directory1\Header1.h"

That should resolve any ambiguities :)



Tue, 28 Aug 2001 03:00:00 GMT  
 Include File Search Order

Quote:

> >My problem is that I tell Visual C++ to use File1.c from Directory1, and
> >File2.c from Directory2.  Both File1.c and File2.c include File1.h.
> >When compiling File1.c I would like Visual C++ to use the File1.h from
> >Directory2.  Directory2 contains a "checked out edited version of the
> >files".

> Why don't you explicitly tell VC where to look? Like

> #include ".\Directory1\Header1.h"

> Or even

> #include "C:\My Projects\Project1\Directory1\Header1.h"

> That should resolve any ambiguities :)

It would, but unfortunately I can't for other reasons.  So I'm still looking
for the answer if anyone knows.

Thanks



Tue, 28 Aug 2001 03:00:00 GMT  
 Include File Search Order
In VC++, Tools-->Options-->Directories gives you a point/click interface for
setting up include paths and path order for the entire tool (regardless of
currently loaded workspace or project).

Project-->Settings...-->C++ tab-->Categories:Preprocessor let's you do it
the harder way on a project-by-project basis.

Greg

Quote:

>Hello,

>I'm using Visual C++ 6.0 and I'm having a problem with the compiler
>picking up the wrong version of an include.

>Example.

>Directory1                Directory2
>File1.c                      File2.c    <------Checked out Version of
>Source
>File1.h                      File1.h     <-----Checked out Version of
>Source

>My problem is that I tell Visual C++ to use File1.c from Directory1, and
>File2.c from Directory2.  Both File1.c and File2.c include File1.h.
>When compiling File1.c I would like Visual C++ to use the File1.h from
>Directory2.  Directory2 contains a "checked out edited version of the
>files".

>It appears that Visuall C++ first looks for includes in the directories
>where it finds the source.  I have included ( \I Directory2) option in
>the project settings and from the help it appears this would not work,
>nor did it.  I tried adding File1.h from Directory2 into the project,
>(so it appeared under the Header Files folder in the Files View), and
>that didn't work either.

>There must be a way! Can someone help?  Thanks much in advance.

>Dean



Tue, 28 Aug 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Include File Search Order

2. the order of searching included files

3. Include Search Order

4. Order of including header files

5. The Order of Include Files

6. Any tool that searches include files?

7. Search path for include (header) files

8. HELP!!! searching for INCLUDE-files

9. Need utility to search include files for string

10. CPP: How to fix include file path search

11. Changing linker search path for MFC/include/ and lib/ files

12. Include file directory search path

 

 
Powered by phpBB® Forum Software