0

I added the Scintilla framework successfully to my XCode project (i.e. it finds the header files correctly), but because it is written in Objective-C++ it doesn't compile. I get 8 syntax errors because of ::s. I already found you can't include Objective-C++ from a pure Objective-C file, so I changed the file extension to mm. It still gives me the same 8 errors.
I also changed the file type (of the importing file) to sourcecode.cpp.objcpp.

The relevant lines of code (with the errors in comments - the line numbers are from the original file, so without the errors in the comments):

ScintillaView.h

// Line 47-49
@protocol ScintillaNotificationProtocol 
- (void)notification: (Scintilla::SCNotification*)notification; // 4 errors on this line:
                                                                //   1. expected type-specifier
                                                                //   2. expected ')'
                                                                //   3. expected identifier
                                                                //   4. expected ';'
@end
// [snip]
// Line 131
- (void) notification: (Scintilla::SCNotification*) notification;   // The exact same errors.

When copying this code I noticed the :: operator is used a few more times in the file, so somehow the parser is only able to match it succesfully in certain places.

Once more, this code is not mine, but taken from the Scintilla Cocoa Library.
(See here for more info: http://www.scintilla.org/)

XCode 3.2.6, Mac OS X 10.6.8

11684
  • 7,356
  • 12
  • 48
  • 71
  • Is there a reason you are not using Xcode 4.2? – Black Frog Apr 12 '14 at 08:52
  • 1
    You are the _third_ person asking that, the second asked it yesterday. Please refer to this comment thread: http://apple.stackexchange.com/questions/127235/erroneous-installation-alert-upon-installing-xcode-3-2-6?noredirect=1#comment149117_127235. @BlackFrog – 11684 Apr 12 '14 at 08:53
  • Even if your paid Apple Developer account is not current, try this (http://stackoverflow.com/questions/10335747/how-to-download-xcode-4-xcode-5-and-get-the-dmg-file) – Black Frog Apr 12 '14 at 09:03
  • @BlackFrog Thank you, but 4.2 is the last version supporting Snow Leopard, and the oldest version in the question you linked to is 4.3.2. – 11684 Apr 12 '14 at 09:09
  • 1
    What about posting the errors? – uliwitness Apr 12 '14 at 10:37
  • @uliwitness They aren't relevant, True errors are because some Objective-C++ code is compiled as vanilla Objective-C, which is not possible. It is not my code, but the code in the Scintilla framework, which, by the way, works fine in the test project included in the download of the library. – 11684 Apr 12 '14 at 13:11
  • @uliwitness I now notice an autocorrect-produced mistake: true=the. – 11684 Apr 20 '14 at 14:17
  • Your code doesn't work. It's spitting out errors. So obviously at least one of them *must* be relevant, or the code would be working. Unless you give us some information, nobody here can guess what is going wrong. – uliwitness Apr 22 '14 at 17:26
  • @uliwitness I messed up the Scintilla Dependency, so I couldn't reproduce the errors for a while. Now I got it, I will post the errors plus code. (By the way, it's not my code.) – 11684 Jun 17 '14 at 13:04
  • Where do you include the declarations of Scintilla::SCNotification etc? – mmmmmm Jun 17 '14 at 13:20
  • They are in `Scintilla.h` which is included by `ScintillaView.h` which is included by `AppController.mm`. @Mark – 11684 Jun 17 '14 at 13:32
  • Lets see exactly how they are called – mmmmmm Jun 17 '14 at 13:34
  • @Mark I included `ScintillaView.h` to be able to do `[[ScintillaView alloc] init];`. But I think I solved it, I'm writing an answer at the moment. – 11684 Jun 17 '14 at 13:37

1 Answers1

0

Adding

typedef tdSCNotification Scintilla::SCNotification

Before the first offending line revealed that there was no type called SCNotification in that namespace. So I searched through the included header files (which, luckily, count only three) for namespace Scintilla {. It was in the first included header file, Scintilla.h. But it looked like this:

#ifdef SCI_NAMESPACE
namespace Scintilla {
#endif

and

#ifdef SCI_NAMESPACE
}
#endif

So I assumed SCI_NAMESPACE wasn't defined. I added #define SCI_NAMESPACE to Scintilla.h somewhere online 45 and it worked. Almost. I got another error message:

Framework not found Scintilla
Command /Developer/usr/bin/llvm-g++-4.2 failed with exit code 1

I think this has to do with how I added the framework to my project, so it should be a separate question.

11684
  • 7,356
  • 12
  • 48
  • 71