RISC OS C Programming FAQ: Difference between revisions
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
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. |
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?? |
'''''Q. Where can I find the latest version of GCC for RISC OS??''''' |
||
The latest release is available from the GCCSDK website. Experimental versions may also be available there. |
The latest release is available from the [GCCSDK website,http://gccsck.riscos.info]. Experimental versions may also be available there. |
||
Q. How do I call a SWI in C? |
Q. How do I call a SWI in C? |
Revision as of 15:50, 28 January 2006
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 [GCCSDK website,http://gccsck.riscos.info]. Experimental versions may also be available there.
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. Also, some types of C++ programming, especially use of templates, generates large amounts of output. Additionally, some types of template construct generate repeated code due to limitations of the AOF format. Finally, ensure you've got optimisation turned on with a -O flag.
Q. Can C++ programs with GCC link with the SharedCLibrary?
Yes, recent versions of GCC support linking C++ with the SharedCLibrary; this may be useful to reduce the size of your output.
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, although it may be that the -fPIC switch already does most of the work for this. Additional work may required in drlink.
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.
Q. Is GCC/UnixLib 32-bit Ready?
All versions of GCC have been 32-bit compatible for a number of years. Producing 26-bit code is no longer supported.
Q. Can GCC use Acorn's linker instead of Drlink?
Yes. In some circumstances it may be desirable to use this instead. In principle, Drlink should do everything that the Acorn linker does, but because of bugs or feature improvements, it may not in a released form.
It is possible to call link directly, but this is not recommend as it will not correctly set the options and libraries that GCC requires. Instead, set the variable:
*set GCC$Linker link
Note that if you do find it neccessary to do this, the GCCSDK team would like to hear about it so Drlink can be fixed.