Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-03-2008, 08:01 AM   #1 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 64
masumbuet is on a distinguished road
Default using C++ with objective-C

Hello,
I can include C++ header files(e.g. vector) in .mm file and use them as well without any error. But when I use #include<vector> in a .h file of objective-C project in xcode, I got "vector: No such file" error.

Is it possible to use c++ header in a .h file? If yes, then how?

Please help. Thanks.
masumbuet is offline   Reply With Quote
Old 12-03-2008, 11:55 PM   #2 (permalink)
New Member
 
Join Date: Nov 2008
Posts: 16
jta23 is on a distinguished road
Default

I just threw
Code:
#include<vector>
in a .h file in my project and recompiled, no errors.

In the project settings, you can set it to compile based on the file type, or you can force it to compile everything as Objective-C++.

I do the later with no problems; what is your settting?
jta23 is offline   Reply With Quote
Old 12-03-2008, 11:57 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 253
zhyla is on a distinguished road
Default

You can mix C++ with Objective-C freely but as far as I can tell there is no STL implementation on the iphone. Or at least I haven't been able to include <vector> either.

When I was starting with the OpenGL ES I had to add a library to my project as "required" so that it could link in some GL routines. Maybe there's some STL libraries that need to be included for this to work?
zhyla is offline   Reply With Quote
Old 12-04-2008, 08:02 AM   #4 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 64
masumbuet is on a distinguished road
Default Confused

But I could use STL in my project, though only in .mm file. But getting problem in .h file.
masumbuet is offline   Reply With Quote
Old 12-04-2008, 08:03 AM   #5 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 64
masumbuet is on a distinguished road
Default

Quote:
Originally Posted by jta23 View Post
I just threw
Code:
#include<vector>
in a .h file in my project and recompiled, no errors.

In the project settings, you can set it to compile based on the file type, or you can force it to compile everything as Objective-C++.

I do the later with no problems; what is your settting?
It worked. Thanks.

Last edited by masumbuet; 12-16-2008 at 11:28 PM.
masumbuet is offline   Reply With Quote
Old 12-04-2008, 10:50 AM   #6 (permalink)
New Member
 
Join Date: Oct 2008
Location: Tokyo, Japan
Posts: 4
ngc1208jpn is on a distinguished road
Default

Check if there is no space after '<' and before '>'.
If you placed space inside brackets, compiler would complain.
ngc1208jpn is offline   Reply With Quote
Old 07-16-2011, 02:21 PM   #7 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 38
AlphaMensch is on a distinguished road
Default

Oh sorry wrong safari-tab I am really sorry
AlphaMensch is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 379
17 members and 362 guests
Absentia, apatsufas, BinHex, cpsclicker, dre, Error404, Gaz, gmarro, jeroenkeij, Kirkout, mottdog, Music Man, PavelMik, teebee74, whitey99, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,666
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, cpsclicker
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:12 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0