Re: XCode picks up headers from the wrong location
Re: XCode picks up headers from the wrong location
- Subject: Re: XCode picks up headers from the wrong location
- From: Andreas Grosam <email@hidden>
- Date: Fri, 2 Apr 2010 20:27:32 +0200
On Mar 29, 2010, at 1:25 PM, Gregor Jasny wrote:
> Hi,
>
> In my project XCode picks up headers that are not mentioned in the HEADER_SEARCH_PATHS.
>
> Imagine a project with the following two files
>
> config/StdAfx.h
> #error "I should not be included"
>
> src/main.cpp
> #include "StdAfx.h"
>
>
> If I add those two files to the project groups and files, the compiler picks up StdAfx.h and stops on the #error. This is very surprising for me because I have not added the config path to the header search path.
>
> If I remove the StdAfx.h file from the files tree, the compiler complains about the missing include file as expected.
>
> Is there a configuration option to disable this behavior?
Use this build setting in the target:
USE_HEADERMAP = NO
(create it, if it does not exist)
This causes Xcode not to use so-called headermaps, which are dictionaries which speed up the search for headers. It seems the dictionary are just "file-name" "paths" associations. This dictionary will be passed to the compiler (preprocessor, more precisely), which only the Apple compiler knows how to treat them.
Unfortunately, the use of header maps may create some incompatibilities regarding header search paths, its order, and also how you write the include statements - as you already experienced yourself.
It's unfortunate that this build setting is still undocumented. And what makes it worse is the fact, that it defaults to YES, and doesn't work always flawlessly.
Although it is possible to use headermaps AND qualified pathnames (like "config/MyHeader.h") it may confuse files if they have not unique names - which is one purpose of the use of qualified header paths. Consider:
#include "A1/config.h"
#include "A2/config.h"
or the infamous:
#include "A3/string.h"
So, if you have something like this, you better off setting USE_HEADERMAP to NO. Don't worry about the speed. Instead, be sure to use precompiled headers, which *really* speed up the process.
I would appreciate it if the use of headermaps is actually transparent - that is, it will not alter the rules set by the standard for the preprocessor.
Andreas
>
> Thanks,
> Gregor
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden