views:

189

answers:

2

I am trying to use c++ in an iphone app. I added the line

#include <cstring>

in one of my files.

I get "error: cstring: no such file or directory". What do I need to do to get it working?

My understanding is that gcc is being called, but not g++. How can I change that, or what flag can I add to force gcc to compile c++?

+4  A: 

Objective-C++ files must have the .mm extension by default in an iPhone app... otherwise it's probably a crazy path setting. Anything weird in the build settings?

Robert Karl
I also have tried a .cpp and an.hpp file in the project. It's not working.
John Smith
What he means is that the Objective-C file has to have the `.mm` extension.
Chris Long
+2  A: 

As @robert said, the easiest way is to name your file .mm instead of .cpp. Or you can pass the compiler flag

-x objective-c++
Jesse Beder
How do you add this flag in XCode?
John Smith