Reputation: 7711
Any ideas why Xcode wont let me define a c++ class in my cocoa project?
I am trying to use a C++ class in my cocoa project but I am getting build errors just creating the c++ header file.
class SomeClass{
public:
int count;
};
Expected '=', ',', ';', 'asm' or 'attribute' before 'SomeClass' in .....
If I remove all code from the header file, ?the cpp file builds without any errors and is included in the list of compiled sources...
Upvotes: 0
Views: 183
Reputation: 95315
Ensure that your Objective-C source files have the .mm
extension so that they are treated as Objective-C++ files (there are other ways of getting Xcode to treat your files as Objective-C++ source even if they don't have the .mm
extension, but it is easier just to use the .mm
extension), and also follow PeterK's advice about appending a semicolon after the class declaration.
Upvotes: 5
Reputation: 6317
I think you need to add a semicolon:
class SomeClass{
public:
int count;
};
Upvotes: 4