Quantcast
Channel: Tools
Viewing all articles
Browse latest Browse all 91752

Forum Post: RE: Search Path for #include Files

$
0
0

Let's start with a simple example ...

// base.c #include "near_by.h" ... 

Where does the compiler look for the file near_by.h?  It looks in the directory where base.c resides.  If you are building a CCS project, this will almost always be the project directory.  

Now, let's add to that example to make it more interesting.  First, show one more line from base.c ...

// base.c #include "near_by.h" #include "path/to/far_away.h" ...

And let's say that far_away.h has this ...

// far_away.h #include "even_farther.h"
...

How is the full directory path to faraway.h formed?  Concatenate the directory which contains base.c with "path/to".  That's an obvious extension to the existing method.

Here is the interesting question: Where does the compiler look for even_farther.h?  There are two reasonable choices:  The directory where far_away.h resides, or the directory where base.c resides.  The TI compiler looks in the directory where far_away.h resides, and only there.  It never looks in the directory where base.c resides.  Other compilers may do this differently.  The standards for C and C++ do not specify this behavior.

For more background on how header files are found, with emphasis on the difference between "this.h" and <that.h>, please check out this video (Please visit the site to view this video).

Thanks and regards,

-George


Viewing all articles
Browse latest Browse all 91752

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>