Difference between revisions of "Writing portable code"

From GNUstepWiki
Jump to navigation Jump to search
(No difference)

Revision as of 13:58, 28 February 2005

GNUstep opens up some fairly interesting opportunities to target a number of platforms with the same source code, for example porting MacOS X Cocoa applications to Linux, the BSDs, other Unices and (ultimately) Windows without significant re-engineering effort or degraded end-user functionality.

Some portability gotchas are listed below (please update when you run into a new one!):

MacOS X developers

...should try and avoid CoreFoundation as this will complicate your dependency situation on non-Mac hosts, even if that part of CoreFoundation has actually been ported.

GNUstep Base and the FoundationKit offer many parts of the CoreFoundation functionality in a natural Objective-C manner.

All the world is not Linux

...or FreeBSD or Windows. System constants may be different on different platforms. Paths to command-line tools, the parameters they accept and locations of temporary directories may be different to what you are used to on your platform.

  • GNUstep Base and the FoundationKit offer some of this functionality "for free".
  • Try not to hard code paths and so on into your code, use macros, or even better an abstraction mechanism.
  • Avoid hard-coding system constants, or platform-specific ones where Posix or commonly-accepted ones exist (and we're not talking about glibc here :-)