RISC OS C Frequently Asked Questions


As always, there are questions which are perennial, and usually have quite simple answers (to those who know them). And quite often, the solution is a FAQ. Here's mine.

Q. Can I ask you for help with my programming problem?

Only if it directly relates to content on this site - e.g., the tutorials - otherwise if it's RISC OS related, you should ask in one of the programming forums, such as comp.sys.acorn.programmer.

Q. Where can I find the latest version of GCC for RISC OS??

The latest release is available from the GCC website. Developmental binaries are available from the AcornSearch autobuilder.

Q. How do I call a SWI in C?

In the first instance, don't. Instead, you should use a library which provides an interface to the SWI - this will give you better type checking, and minimise any mistakes.

If you still need to call a SWI, then you can use the _swix and _kernel_swi functions provided by SharedCLibrary and Unixlib. Alternatively, you may find it easier to use a SWI library such as the one I have written. Desklib et. al. also provide a SWI interface function.

Q. Why are C++ programs with GCC so big?

Firstly, GCC programs by default link with UnixLib, which is statically linked to your progran. There is a minimum of about 80k added to your code. Secondly, some types of C++ programming, especially use of templates, generates large amounts of output. Finally, ensure you've got optimisation turned on with a -O flag.

Q. Can C++ programs with GCC link with the SharedCLibrary?

In general, no. But if you aren't using certain libraries then you may be able to. This will reduce the size of your output. The reason is that the C++ libraries supplied with GCC are only suitable for Unixlib.

From the GCC examples:

  gcc -mlibscl helloworld.cc -o helloworld -liostream

Will fail, whilst:

  gcc -mlibscl template.cc -o template

will succeed.

This could be made to work, however. But no one has yet put in the effort.

Q. Why can't GCC/LCC create modules?

Simply - because the compiler ARM backends cannot generate the correct code for module behaviour. Again, this is because no one has yet put in the effort.

For more detail, see this message.

Q. Where can I get GNU Make/other tools for RISC OS?

Make is available in the GCC distribution along with other tools including find, gzip, grep, etc.