• 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: Miss #include <vector>
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Miss #include <vector>


  • Subject: Re: Miss #include <vector>
  • From: Rush Manbert <email@hidden>
  • Date: Tue, 21 Mar 2006 14:46:23 -0800

Nick Zitzmann wrote:

On Mar 21, 2006, at 2:45 PM, Lorenzo wrote:

My compiler says "error: vector: No such file or directory"
on the line:

    #include <vector>

What should I include/link in order to get it to run?


What is the extension of the source file? That ought to just work if the file has a .cpp or .mm extension.


Funny, this is also being discussed on the Xcode list. Because of that, I can say that you can also see this if you compile file.m, which is pure objective-c, but somewhere in its import chain, a header file is included that includes <vector>, something like this:



imports imports includes FileA.m ------->FileB.h------->FileC.h--------> <vector> Obj-C Obj-C Obj-C++ C++

The compile on FileA.m will fail with the error described in the initial post.

It seems that you could probably put conditionals into FileC.h that protect the compiler from seeing the <vector> include, but that probably opens up a whole can of worms with the FileC public interface. It seems to me that the best thing to do in this case is to change your build settings and tell the compiler to "Compile Sources As" Objective-c++. I haven't seen anything bad happen from doing this, and it makes mixed Obj-C/C++ development a lot easier.

Is there any reason to avoid this solution?

- Rush
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Miss #include <vector>
      • From: Lorenzo <email@hidden>
References: 
 >Miss #include <vector> (From: Lorenzo <email@hidden>)
 >Re: Miss #include <vector> (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: NSTreeController selected object changing my model
  • Next by Date: NSView Updates from Drawer Buttons
  • Previous by thread: Re: Miss #include <vector>
  • Next by thread: Re: Miss #include <vector>
  • Index(es):
    • Date
    • Thread