RISCOS.com

www.riscos.com Technical Support:
Acorn C/C++

 

Introduction


Acorn C/C++ is a development environment for producing RISC OS desktop applications and relocatable modules written in ANSI C and/or in C++. It consists of a number of programming tools which are RISC OS desktop applications. These tools interact in ways designed to help your productivity, forming an extendable environment integrated by the RISC OS desktop. Acorn C/C++ may be used with Acorn Assembler (a part of this product) to provide an environment for mixed C, C++ and assembler development.

Acorn C/C++ includes tools to:

  • edit program source and other text files
  • search and examine text files
  • convert C source and header text between ANSI and UNIX dialects
  • examine some binary files
  • compile and link C programs
  • compile and link C++ programs
  • construct relocatable modules entirely from C or C++
  • compile and construct programs under th e control of makefiles, these being set up from a simple desktop interface
  • squeeze finished program images to occupy less disk space
  • construct linkable libraries
  • debug RISC OS desktop applications interactively
  • design RISC OS desktop interfaces and test their functionality
  • use the Toolbox to interact with those interfaces.

Most of the tools in this product are also of general use for constructing applications in other programming languages, such as ARM Assembler. These non-language-specific tools are described in the accompanying Desktop Tools guide.

Installation of Acorn Desktop C

Installation of Acorn C/C++ is described in the Installing Acorn C/C++ of the accompanying Desktop Tools guide .

The C compiler

The Acorn C compiler for RISC OS (the tool CC supplied as a part of this product) is a full implementation of C as defined by the 1989 ANSI language standard. To obtain this standard document, see the chapter entitled Useful references. It is tested with the Plum-Hall C Validation Suite version 2.00, and passes all sections, except for failing to produce two required diagnostic messages, as described in the release note accompanying this user guide.

The C++ translator

The C++ translator for RISC OS (the tool C++ supplied as a part of this product) is a port of Release 3.0 of AT&T's CFront product.

This user guide

This guide is a reference manual for the C tools CC, C++, CMHG, ToANSI and ToPCC working as part of the development environment of Acorn C/C++. These are the only tools in this product which are not used for programming in other languages, and already described in the accompanying Desktop Tools guide. This manual also documents the C and C++ library support provided and other aspects that are particular to this C product:

  • special features of this implementation of the C and C++ languages
  • operating the Acorn C/C++ tools specific to the C and C++ languages
  • developing programs for the RISC OS environment:
    • Portability issues, including the portable C compiler (pcc) facility
    • Desktop applications
    • Relocatable modules
    • Overlays
    • Calling other programs and languages from C.

This guide is not intended as an introduction to C or C++, and does not teach C or C++ programming; nor is it a reference manual for the ANSI C standard. Both these needs are addressed by publications listed in the Useful references.

This guide is organised into parts:

Part 1 - Using the C tools

Part 2 - C language issues

Part 3 - C++ language issues

Part 4 - Developing software for RISC OS

Part 5 - Appendixes

Part 1 - Using the C tools

This part of the guide describes the operation of the programming tools specific to C. The first chapter describes the interaction of the C tools with the rest of the development environment; each of the remaining chapters is devoted to an individual tool. Examples in the text and on disc are used to illustrate several points.

The chapters are:

Part 2 - C language issues

This covers issues to do with the C programming language itself, in particular those parts of the ANSI standard that are necessarily machine- or operating system-specific.

The chapters are:

  • C implementation details

    How Acorn C implements those aspects of the language which ANSI leaves to the discretion of the implementor; and how Acorn C behaves in those areas covered by Appendix A.6 of the draft standard (which lists those aspects which the standard requires each implementation to define).

  • The C library

    This chapter works through the headers of the C library, (assert.h to time.h), outlining the contents of each one:

    • function prototypes
    • macro, type and structure definitions
    • constant declarations.
  • The ANSI library

    This chapter details the ANSI library, a superset of the C library that provides additional features useful in debugging and profiling your software.

  • The Event library

    This chapter details the Event library, which provides calls for you to more easily dispatch Toolbox and Wimp events within Toolbox based applications.

  • The Wimp library

    This chapter documents the Wimp library, which provides a set of C veneers onto the Wimp (or Window Manager) SWI interface.

  • The Toolbox library

    This chapter documents the Toolbox library, which provides a set of C veneers onto the Toolbox SWIs.

  • The Render library

    This chapter documents the Render library, which provides a set of C veneers onto the DrawFile SWIs, used to render Draw files.

Part 3 - C++ language issues

This covers issues to do with the C++ programming language, such as details of its implementation and of the libraries supplied with it.

  • C++ implementation details

    This chapter describes implementation specific behaviour of Acorn C++.

  • The Streams library

    This chapter describes the C++ Streams library, giving a synopsis (including prototypes) and a description of each available interface.

  • The Complex Math library

    This chapter describes the C++ Complex Math library, giving a synopsis (including prototypes) and a description of each available interface.

Part 4 - Developing software for RISC OS

This part of the Guide tells you how to write software in C for the RISC OS environment. Examples in the text and on disc are used to illustrate each type of program development. It also includes a chapter on portability to help with porting applications in C to and from RISC OS.

The chapters are:

  • Portability

    The chapter covers:

    • portability considerations in general
    • the major differences between ANSI and 'K&R' C
    • using the pcc compatibility mode of the Acorn compiler
    • standard headers and libraries
    • environmental aspects of portability.
  • Assembly language interface

    How to handle procedure entry and exit in assembly language, so that you can write programs which interface correctly with the code produced by the C compiler.

  • How to write relocatable modules in C

    Relocatable modules - the building blocks of the RISC OS operating system - are needed for device drivers and similar low-level software.

  • Overlays

    This chapter explains how to write an application using overlays, with a worked example as an illustration.

Part 5 - Appendixes

The appendixes are:

  • Changes to the C compiler

    This is the fifth release of the C compiler product for Acorn computers running the RISC OS operating system. The appendix highlights all those features that are new since the previous release (Acorn Desktop C).

  • C errors and warnings

    Messages produced by the compiler, of varying degrees of severity.

  • C++ errors and warnings

    Messages produced by the translator, of varying degrees of severity.

Conventions used

Throughout this Guide, a fixed-width font is used for text that the user should type, with an italic version representing classes of item that would be replaced in the command by actual objects of the appropriate type. For example:

cc options filenames

This means that you type cc exactly as shown, and replace options and filenames by specific examples.

Where it is necessary to differentiate between text you type, and that output by the computer, your input is shown in bold, and the computer's response in a normal weight.

Useful references

C programming
  • Harbison, S P and Steele, G L, (1984) A C Reference Manual, (second edition). Prentice-Hall, Englewood Cliffs, NJ, USA. ISBN 0-13-109802-0.

    This is a very thorough reference guide to C, including a useful amount of information on the ANSI C standard.

    Since the Acorn C compiler is an ANSI compiler, this book is particularly relevant, but you must get the second edition for coverage of the ANSI standard.

  • Kernighan, B W and Ritchie, D M, (1988) The C Programming Language (second edition). Prentice-Hall, Englewood Cliffs, NJ, USA. ISBN 0-13-110362- 8.

    This is the original C 'bible', updated to cover the essentials of ANSI C too.

  • Koenig, A, (1989) C Traps and Pitfalls, Addison-Wesley, Reading, Mass, USA. ISBN 0-201-17928-8.

    This book explains how to avoid the most common traps and pitfalls that ensnare even the most experienced C programmers. It provides informative reading at all levels.

C++ Programming
  • Stroustrup, B, (1991) The C++ Programming Language, (second edition). Addison-Wesley, Reading, Mass, USA. ISBN 0-201-53992-6.

    The standard book describing the C++ language, including a complete copy of the Reference Manual.

  • Ellis, A and Stroustrup, B, (1990) The Annotated C++ Reference Manual. Addison-Wesley, Reading, Mass, USA. ISBN 0-201-51459-1.

    The original Reference Manual, used as an ANSI base document, with additional annotations and commentary sections.

RISC OS
  • The User Guide supplied with your computer, which describes how to use the RISC OS operating system and the applications Edit, Paint and Draw.
  • The RISC OS 3 Programmer's Reference Manual.
  • The RISC OS 3 Style Guide.
The ANSI C standard

The American National Standard for Information Systems - Programming Language C is available with the reference number ANSI X3.159-1989 for £45.00 from:

British Standards Institution
Foreign Sales Department
Linford Wood
Milton Keynes
MK14 6LE

Members of the BSI can order copies by telephone; non-members should send a cheque payable to BSI.

However, you should find the coverage of ANSI C in this manual and the books listed above adequate for all but the most demanding requirements.

The ANSI C++ standard

At the time of going to press, the ANSI standard for C++ was not yet published - but it is unlikely to deviate significantly from The Annotated C++ Reference Manual referred to above.

© 3QD Developments Ltd 2013