On Mar 28, 2006, at 12:47 PM, David Dunham wrote: On 28 Mar 2006, at 11:51, Brad Oliver wrote:
#include "system/io.h" #include "system/Hashtable.h"
and I have dragged those two files into the project. But they're not found. I have this directory as a header search path.
I'd change the search path to contain the parent folder of "system" instead. I think the partial-path specification is what's working against you here.
Thanks, that works. I keep getting tripped up by "All headers in your project are automatically accessible to your source code. You can also specify additional search paths at which to find headers using the HEADER_SEARCH_PATHS build setting, described in "Editing Search Paths"," in the Xcode 2.2 User Guide. This statement is simply not true -- the header is in the project, and it is not accessible. (I've just given feedback on the document. Now I just have to get this statement un-burned from my brain, since I think I hear it in every Xcode talk I've ever attended.)
I think you're missing Brad's point. When you added the header files, you added
/Root/subfolder/system/io.h
And Xcode added the parent path
/Root/subfolder/system
to your HEADER_SEARCH_PATHS. So if you just #included "io.h" everything would work. But your source #includes "system/io.h". So what the compiler actually is looking for (you can check this out for yourself by adding -v to Other C Flags) is this:
/Root/subfolder/system/system/io.h
because you told it to in your source code.
Doubtless you, or the code you're using, had some specific intent in putting io.h in a "system" directory and referring to it that way in an #include. If you were using CodeWarrior or Visual Studio or makefiles, you'd have to set things up so that the compiler searched <whatever>/system/ to find io.h.
It's both error-prone and impractical for Xcode to examine all project sources when you add io.h and notice that you're actually #including "somerandomdirectory/io.h". Especially if you have multiple headers with the same name (which is the usual reason to refer to them in subdirectories) it is not reliable for the IDE to guess which one you mean.
I'm sorry if it seems that Xcode is being persnickety and forcing you to be precise, but in this case, the risks of making assumptions are far worse, that is, having to scan all your project sources when you add a header to find out the numerous ways you might be referring to it, and adding potentially ambiguous search paths.
Chris |