1

I tried to import a C++ library into XCode, I renamed the .cpp to .mm but when I try to compile it shows me errors like this:

DateOps.h:23: error: expected '=', ',', ';', 'asm' or '_attribute_' before 'DateOps'

start of DateOps.h file

#if !defined( DATE_OPS__H )
#define DATE_OPS__H
typedef int MonthDays[13];
typedef long YearEndDays[2];
class DateOps {
public:
 enum CalendarType {
 T_GREGORIAN = 0,
 T_JULIAN = 1,
 };

...

asked May 15, 2012 at 14:47
1
  • 4
    Show us the start of DateOps.h and also how you are including it. Commented May 15, 2012 at 14:59

2 Answers 2

1

If you only have to compile a couple files as Objective-C++, then the answer that WrightsCS gave will work fine. However, if you have lots of files to compile this way, or think your project will get bigger in the future, you can change the compilation language for all files:

Go to the Build Settings for your target, look under the Language section for a setting called Compile Sources As. Usually it is set to "According to File Type" (which should work with the .mm extension, but I've seen bugs where it still compiles as Objective-C before). You can force it to "Objective-C++" by changing this setting.

answered May 15, 2012 at 15:05
Sign up to request clarification or add additional context in comments.

Comments

0

You need to set -x objective-c++ as a Compiler Flag on the .mm file you are referring to.

enter image description here

answered May 15, 2012 at 14:57

1 Comment

I didn't have to do that and all my source files are Objective-C++.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.