4 ObjectiveC

Since GNUstep is primarily written in ObjectiveC the C language coding standards largely apply with modifications as specified in the previous section.

One of the primary objectives of GNUstep is portability (both that the GNUstep core code should be portable to very many platforms, and that applications written to use GNUstep should therefore be work on all those platforms). As such, we retain compatibility with old toolchains.

Currently GNUstep targets the Objective-C 2.0 dialect (as supported by the GCC version 4.9.4), but we do not lightly break compatibility with older code, so most code is expect to be written in traditional Objective-C, using macros to support 2.0 features.

Classes implementing newer, inherently non-portable APIs designed by Apple will be supported bay GNUstep, but only to the minimum level needed to aid software built on Apple systems to work cross-platform as a transition to being written more portably.

The main non-portable (implemented only by clang) features Apple added after 2.0 are ARC (Automated Reference Counting) and blocks.

The gnustep-make tool supports turning ARC on/off for projects and/or individual files, and gnustep-base provides macros to make it possible to write code which will work either with or without ARC. Core GNUstep code cannot use ARC, but should use the macros so that we might use it on some platforms in future.

In particular, blocks are completely non-portable and must never be used internally (though methods with block arguments are provided for compatibility with the Apple APIs). As well as being similar to the ’goto’ operation in making code hard to maintain, blocks have a number of issues which mean they are never likely to become standard across compilers (eg https://thephd.dev/lambdas-nested-functions-block-expressions-oh-my).