Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Aikiman

macrumors member
Original poster
Jan 24, 2008
33
0
Im starting some tutorials online on gaming, perhaps some of yous know the ones from lazy Foo' Productions. The 2nd tut has only 2 include directives one of them being #include <string>. Now to do these tuts I have to download the SDL libraries which doesnt appear to have this string definition, am I wrong to assume that Apple ships with the STL libraries as I believe its this library that defines string.

I dug around in the frameworks and couldnt find STL, is the absence of this the reason I am getting a compile error with #include <string>?

Thanks J
 
This header should definitely be there. What exactly are you using to compile your tutorials?
 
You haven't given much detail about the exact error you are seeing so we can only give general suggestions for now. But from my experience with C/C++ in Windows and Solaris:

There is a difference between C and C++. In C, you would have to specify <string.h>, whereas in C++ you can simply specify <string>. Check what kind of project you have created.
 
Im starting some tutorials online on gaming, perhaps some of yous know the ones from lazy Foo' Productions. The 2nd tut has only 2 include directives one of them being #include <string>. Now to do these tuts I have to download the SDL libraries which doesnt appear to have this string definition, am I wrong to assume that Apple ships with the STL libraries as I believe its this library that defines string.

I dug around in the frameworks and couldnt find STL, is the absence of this the reason I am getting a compile error with #include <string>?

Thanks J

Did you install the complete XCode?
If so, is your source file a C++ file or a C file? What is the exact filename?
 
Hi guys,
sorry about the lack of info, I just assumed being Mac forums that everyone would know Im using Xcode. Anyways I have created an SDL application to learn basic game structure which appears to create a .c file which I find a bit unusual because this code comes from the tuts which ue an SDL app template.

Okay so Ive changed the header to <string.h> and that no longer causes me errors. However no theres another related error with "std::string" further down saying "syntax error before ":" token" is this related.

Thanks for your help.
 
Hi guys,
sorry about the lack of info, I just assumed being Mac forums that everyone would know Im using Xcode. Anyways I have created an SDL application to learn basic game structure which appears to create a .c file which I find a bit unusual because this code comes from the tuts which ue an SDL app template.

Okay so Ive changed the header to <string.h> and that no longer causes me errors. However no theres another related error with "std::string" further down saying "syntax error before ":" token" is this related.

Thanks for your help.

Xcode will compile a '.c' file as ordinary C. std::string is C++. Easiest thing to do is to right click on the file in Xcode and rename it to .cpp, then it'll be identified as a C++ source file.
 
Xcode will compile a '.c' file as ordinary C. std::string is C++. Easiest thing to do is to right click on the file in Xcode and rename it to .cpp, then it'll be identified as a C++ source file.

excellent.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.