Can I use STL and C++ in ithe iPhone?
Hi all!
I know is possible to use C++ developing a game for the iPhone (under xcode)
My question is: is Standard Template Library available? and can I use Unicode?
Thanks.
I know is possible to use C++ developing a game for the iPhone (under xcode)
My question is: is Standard Template Library available? and can I use Unicode?
Thanks.
Yes, the STL is available.
Not sure about unicode, I'd imagine so, but haven't tried so can't say for sure.
Not sure about unicode, I'd imagine so, but haven't tried so can't say for sure.
Yes, STL is available (my engine uses it heavily).
I'm not using the native Cocoa libraries, I'm using freetype, so yes, Unicode is possible.
I'm not using the native Cocoa libraries, I'm using freetype, so yes, Unicode is possible.
I was just thinking about this because I sure do need a lot of the STL functionality. Curious, how do you go about using STL? It's not as simple as just including it because of the way Obj-C interprets the < > brackets. What's the trick?
Also, #include <vector.h> or #include <vector> caused an error. Where is it located?
I would sure like to know how to use a templated C++ class. I have a linked list that would be very useful in my game.
Also, #include <vector.h> or #include <vector> caused an error. Where is it located?
I would sure like to know how to use a templated C++ class. I have a linked list that would be very useful in my game.
bmantzey Wrote:I was just thinking about this because I sure do need a lot of the STL functionality. Curious, how do you go about using STL? It's not as simple as just including it because of the way Obj-C interprets the < > brackets. What's the trick?
The compiler looks at the file extension. If it's .cpp, it will use the standard gcc compiler. Everything works exactly the same as C++ only environments.
If you are mixing obj-c code and C++, rename the files with obj-c code to .mm. The compiler will be smart enought to know the difference between [NSilb method] and std::stl methods.
Thats all there is to it.
It's not *quite* all there is to it. Including a C++ object by value in an ObjC class doesn't work the way you want by default. There's a compiler option which tries, or you can use "placement" new yourself, or (frequently easier) only put C++ objects in ObjC classes by pointer.
smallstepforman Wrote:The compiler looks at the file extension. If it's .cpp, it will use the standard gcc compiler. Everything works exactly the same as C++ only environments.
If you are mixing obj-c code and C++, rename the files with obj-c code to .mm. The compiler will be smart enought to know the difference between [NSilb method] and std::stl methods.
Thats all there is to it.
Excellent! Thank you!
I am at the point now where I need to use this template class I wrote. It's a circular linked list, which is really the most optimal way to achieve what I need. It needs to be a linked list and I don't think NSArray objects will work because there will be situations where an element in the list will change, and it will then need to follow that branch.
Anyway, the compiler does not like including a .h that is a templated class. I tried changing it to .mm and it liked that even less. How do I get a templated class into my project?
Edit: I think I may be on my way to figuring this out. I'm not getting the bunch of errors as I was before but now I am getting a lot of warnings regarding the constructor and destructor. Apparently, they constructor and destructors are not called if they are user defined?
Anyway, the compiler does not like including a .h that is a templated class. I tried changing it to .mm and it liked that even less. How do I get a templated class into my project?
Edit: I think I may be on my way to figuring this out. I'm not getting the bunch of errors as I was before but now I am getting a lot of warnings regarding the constructor and destructor. Apparently, they constructor and destructors are not called if they are user defined?
read up a couple posts

