Programming Languages

The C programming language is the primary way to utilize the Amiga's API. As such, all the examples and code snippets in this article are written in C. Since C99 has been around for at least 10 years now, C99 will be the primary language.

For C++ users, the usual way to approach coding on the Amiga is to wrap the C API in thin classes using various design patterns.

Other programming languages exist for programming the Amiga but my focus in this article will remain on C with a sprinkle of C++ for good measure.

The Standard C Compiler

The GNU GCC toolset is the officially supported standard compiler suite for Amiga programming. An alternative C compiler named vbcc is also supported and is popular with some programmers. This article will focus on GCC which supports both C and C++ and includes a complete suite of additional programming tools.

Some Amiga-specific extensions to the baseline GNU GCC have been made to support the new Exec Interfaces, switching C standard libraries and more. The source code for GNU GCC is readily available from the Amiga Development Tools web site and you are encouraged to participate if you are able.

There is a large wealth of detailed documentation and support for GNU GCC and programmers are encouraged to search around the internet. This article will focus on the Amiga-specific extensions where applicable.

The C Standard Library

AmigaOS officially uses a variant of the Newlib C standard library implementation. For programmers, it is essential to know what your C standard library is and what its limits are. Functions may or may not be available. Behaviour may or may not be identical between C standard library implementations.

A popular alternative C standard library implementation is called clib2 and it is included as an option with the standard Amiga SDK. The clib2 library is particular well suited for porting software from the Unix world. The complete source code for clib2 is also available which makes is possible to debug complex problems involving the C library itself.

Switching between C standard library implementations involves using an Amiga-specific extension to GCC. The -mcrt option is used for both compiling and linking:
-mcrt=newlib (default, always thread-safe)
-mcrt=clib2 (non-thread safe version)
-mcrt=clib2-ts (thread-safe version)