• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: search paths
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: search paths


  • Subject: Re: search paths
  • From: Andreas Grosam <email@hidden>
  • Date: Sat, 2 Apr 2005 13:08:51 +0200


On 02.04.2005, at 00:13, Steve Mills wrote:

On Apr 1, 2005, at 14:21, Andreas Grosam <email@hidden> wrote:

When you get compile errors you should check this:
In order to check where the compiler you are using searches for
standard headers, open Terminal and type the follwing into the console:

touch foo.h
gcc -x c++ -v -M foo.h

Ensure "gcc" is acutally the compiler you are using! My XCode uses
gcc-3.3. Take a look into the detailed build result in XCode and figure
out which compiler is actually called.

The first command creates an empty file named "foo.h".

The second command calls gcc and causes it to print out some usefull
information (option -v).
We are intereseted in the search paths.
In the Terminal window you should read something like this:
#include <...> search starts here:
/usr/include/gcc/darwin/3.3/c++
/usr/include/gcc/darwin/3.3/c++/ppc-darwin
/usr/include/gcc/darwin/3.3/c++/backward
/usr/include/gcc/darwin/3.3
/usr/include

Mine is using 4.0, and string is indeed within in /usr/include/gcc/darwin/4.0/c++/.

2) Also check if you did not inadvertently compiled your sources with
an option "-nostdinc++". If this is the case, the compiler will not use
the implicit search paths for C++ standard headers. Again take a look
into the detailed build result and check the options passed to the
compiler.

That option is not on.

One thing I tried was setting the target's "Compile Source As" setting to C++ instead of "According to file suffix". That fixed the problem of it not finding <string>.

Well, XCode will precompile headers for each language which will be used in one target. That means, when you have C and C++ source files in one target, XCode will precompile the prefix header twice: one as C++ and the other as C version - each appropriate for implicit inclusion for the corresponding source files. Any other treatment would be an error!

If you have one prefix file which is used for both languages, you should use macros to exclude C++ sections using a conditional macro like this:

#include <Carbon/Carbon.h>

#if defined (__cplusplus)
#include <string>
#endif

Note: with gcc you can't C-compile C++ source.

Of course, when you compile all C files explicitly as C++, then only one prefix header will be compiled - in the C++ version.

Regards
Andreas
[snip]


 _______________________________________________
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

References: 
 >Re: search paths (From: Steve Mills <email@hidden>)

  • Prev by Date: Re: search paths
  • Next by Date: Frameworks included in an applications bundle
  • Previous by thread: Re: search paths
  • Next by thread: Re: search paths
  • Index(es):
    • Date
    • Thread