views:

958

answers:

5

Objective-C 2.0 has some new enhancements:

  • garbage collection
  • fast enumeration: for..in
  • properties
  • thread synchronization: @synchronized(self)
  • @try/@catch/@finally/@throw exception handling

I'm interested in using Objective-C 2.0 as a language to program portable code across multiple operating system platforms - while avoiding frameworks such as OpenStep or GNUStep.

However, though gcc 3.4.5 on Windows will parse the syntax of using @try/@catch/@finally/@throw exception handling when compiling with -fobjc-exceptions, it still generates this error:

error: storage size of '_stackExceptionData' isn't known

Is there any support of Objective-C 2.0 features on operating systems other than Mac OS X v10.3 and later?

+1  A: 

Apple uses a variant/fork of the standard GCC, in which Objective-C 2.0 support is built-in. As far as I know, none of the Objective-C 2.0 features exist in the standard GCC.

I'm not exactly sure about exception handling, but the other features you listed, unfortunately, are not available on other platforms.

P.S. GNUstep (and Cocoa) is an implementation of OpenStep, which is a specification.

sebnow
+1  A: 

The features in question require both compiler and runtime support and so, while it is certainly possible to build a compiler that supports the syntax (LLVM/Clang comes to mind) many of these features call out to the Objective-C runtime and, to my knowledge (and quick double checking on Google) the GNU runtime doesn't have the necessary support.

wisequark
+2  A: 

Quote from Cocotron gets some Objective-C 2.0 support via gcc 4.3.0:

Recent Cocotron patches by Johannes also completely enable @try/@catch which had been present in the compiler but needed runtime support.

www.cocotron.org about what Cocotron is:

The Cocotron is an open source project which implements an Objective-C API similar to that described by Apple Inc.'s Cocoa documentation. This includes the AppKit, Foundation, Objective-C runtime and support APIs such as CoreGraphics and CoreFoundation

So if you are interested in cross-platform obj-c development Cocotron might be interesing for you ...

f3lix
A: 

There's a cross-platform runtime as part of the Étoilé project which supports Objective-C exceptions (and @synchronized as a result) and, AFAIK, properties:

http://www.nabble.com/ANN:-New-Objective-C-Runtime-td13648692.html

By the way, Objective-C language exceptions aren't an Objective-C 2.0 feature. They've been in the NeXT runtime since Panther.

Graham Lee
A: 

@try/@catch/@finally/@throw actually predates Objective-C 2.0. It was introduced with MacOSX 10.3 while Objective-C 2.0 was introduced with 10.5 (Leopard).

mfazekas