John Smith
John Smith

Reputation: 12797

Trying to use C++ in an iPhone app

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++?

Upvotes: 3

Views: 463

Answers (2)

Jesse Beder
Jesse Beder

Reputation: 34034

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++

Upvotes: 3

Robert Karl
Robert Karl

Reputation: 7816

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?

Upvotes: 4

Related Questions