#include - brackets vs quotes in XCode?

Posted by Chris Becke on Stack Overflow See other posts from Stack Overflow or by Chris Becke
Published on 2010-05-11T11:16:36Z Indexed on 2010/05/11 11:24 UTC
Read the original article Hit count: 225

Filed under:
|
|

In MSVC++ #include files are searched for differently depending on whether the file is enclosed in "" or <>. The quoted form searches first in the local folder, then in /I specified locations, The angle bracket form avoids the local folder.

This means, in MSVC++, its possible to have header files with the same name as runtime and SDK headers.

So, for example, I need to wrap up the windows sdk windows.h file to undefine some macro's that cause trouble. With MSVS I can just add a (optional) windows.h file to my project as long as I include it using the quoted form :-

// some .cpp file
#include "windows.h" // will include my local windows.h file

And in my windows.h, I can pull in the real one using the angle bracket form:

// my windows.h
#include <windows.h> // will load the real one
#undef ConflictingSymbol

Trying this trick with GCC in XCode didn't work. angle bracket #includes in system header files in fact are finding my header files with similar names in my local folder structure. The MSVC system means its quite safe to have a "String.h" header file in my own folder structre. On XCode this seems to be a major no no.

Is there some way to control this search path behaviour in XCode to be more like MSVC's? Or do I just have to avoid naming any of my headers anything that might possibly conflict with a system header. Writing cross platform code and using lots of frameworks means the possibility of incidental conflicts seems large.

© Stack Overflow or respective owner

Related posts about c++

Related posts about xcode