using c++ stl in cocoa (obj-c)?

FreeKQuency23
Unregistered
 
Post: #1
I am a c++ programmer that is new to objective-c and cocoa and need stl container functionality like vectors, trees, lists, maps, etc...

From doing research, Ive found two possibilities:
Somehow use objective c++ and use the good old "c++ with STL" ,

Or use "objective-c and ObjectiveLib" which seems to be a port of the stl to objective-c:
http://objectivelib.sourceforge.net/

My question is then:
1. Any advice on which is the prefered method for game programming? I would think the first would be more cross platform compatible.

2. How would I link in to using said method? what frameworks would i need to add to my project etc..

Thank you.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
You could

* just use NSSet, NSDictionary, NSArray, etc.
* use Objective-C++ and actually use the STL
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #3
What I usually do is split the code base into Obj-C++ for the GUI and have it pass data to/from the game logic code written in standard C++, which of couse can use the STL as OSC has pointed out.

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
FreeKQuency23
Unregistered
 
Post: #4
I think I definitely prefer the obj-c++ method, since Ive used the stl for years + i can port to windows/linux if i choose.

That being said Ive been trying to get the xcode compiler to recognize c++ libraries..
#include <iostream>
throws a compiler error. I put this in the .h file that belongs to a .mm file.
wtf?

How do you include c++ into an xcode proj? I think ive followed the release notes correctly.
When making the file do I make an obj-c cocoa file and rename it to .mm?
lost....
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
make sure the .h isn't included from a non-c++ source file...
Quote this message in a reply
FreeKQuency23
Unregistered
 
Post: #6
Thanks everyone for your help.

I got it working by making all source files have the .mm extension (and header .h).
I have no .cpp and no .m files.

Not sure if this is the best way, but it seems to work..

Thanks again
Quote this message in a reply
Member
Posts: 198
Joined: 2005.01
Post: #7
We've been using Boost at work a lot lately. It might be killer if someone wrote a shared_ptr implementation for ObjC objects, to automatically do reference counting. Or just an auto-ref/deref wrapper even. I wonder if anyone has done something like that.

Cryptic Allusion Games / Cryptic Allusion, LLC
http://www.cagames.com/
Quote this message in a reply
Post Reply