Include File Search Order 
Author Message
 Include File Search Order

I'm having a problem with the way Visual C++ 6.0 and how it determines
what include files to use. I have a directory that has a bunch of
include files.

C:\myDirectory\Includes\
                                    file1.h
                                    file2.h

Assume file1.h includes file2.h.  I checkout file2.h to another
directory using custom source control program independent of Visual C++.
and make some changes.

C:\checkoutDirectory\file2.h

In Project|Settings I have added the following to the "Additional
Include Directories" line.

C:\checkoutDirectory, C:\myDirectory\Includes.

I then compile my C++ source part which includes file1.h. Visual C++
finds it no problem in C:\myDirectory. Unfortunately because file1.h
includes file2.h, it uses the file2.h from C:\myDirectory instead of
C:\checkoutDirectory because the file2.h exists where file1.h lives EVEN
THOUGH I specifically told it to look in C:\checkoutDirectory FIRST!

Is this how Visual C++ works?

Thanks for the help!



Tue, 11 Sep 2001 03:00:00 GMT  
 Include File Search Order

Quote:

>I'm having a problem with the way Visual C++ 6.0 and how it determines
>what include files to use. I have a directory that has a bunch of
>include files.

>C:\myDirectory\Includes\
>                                    file1.h
>                                    file2.h

>Assume file1.h includes file2.h.  I checkout file2.h to another
>directory using custom source control program independent of Visual C++.
>and make some changes.

>C:\checkoutDirectory\file2.h

>In Project|Settings I have added the following to the "Additional
>Include Directories" line.

>C:\checkoutDirectory, C:\myDirectory\Includes.

>I then compile my C++ source part which includes file1.h. Visual C++
>finds it no problem in C:\myDirectory. Unfortunately because file1.h
>includes file2.h, it uses the file2.h from C:\myDirectory instead of
>C:\checkoutDirectory because the file2.h exists where file1.h lives EVEN
>THOUGH I specifically told it to look in C:\checkoutDirectory FIRST!

>Is this how Visual C++ works?

If file1.h says:

 #include "file2.h"

VC looks inside file1.h's folder first. (Look up #include in the VC
documentation for the exact lookup rules.) IMO, this is the most sensible,
useful way to implement this type of #include; it closely parallels
namespaces, where path names are like namespace names. If you want VC to
look at just the -I and INCLUDE directories, you'll need to use:

 #include <file2.h>

That seems inappropriate here. I think your problem lies in your source
control method. The files you want to compile need to live in the same place
from compile to compile.

--
Doug Harrison



Tue, 11 Sep 2001 03:00:00 GMT  
 
 [ 2 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