GCC for beginners

From RISC OS

(Difference between revisions)
Jump to: navigation, search
(Create page as a response to comp.sys.acorn.programmer thread - add some text from a posting)
(Add introduction and Makefiles question)
Line 1: Line 1:
-
= Header file naming =
+
This page is intended to be a collection of tips for those who are new to GCC on RISC OS, perhaps those who are used to Acorn C/C++.  For a tutorial, see also the [[GCC tutorial]].
 +
= Makefiles =
 +
See this question in the [[RISC_OS_C_Programming_FAQ#How_do_I_write_Makefiles.3F|RISC OS C Programming FAQ]].
 +
 +
= Header file naming =
On Unix, there's a given hierarchy of header files.  So when you install the
On Unix, there's a given hierarchy of header files.  So when you install the
C library header files (equivalent to UnixLib) they go in /usr/include.
C library header files (equivalent to UnixLib) they go in /usr/include.

Revision as of 14:44, 27 November 2007

This page is intended to be a collection of tips for those who are new to GCC on RISC OS, perhaps those who are used to Acorn C/C++. For a tutorial, see also the GCC tutorial.

Makefiles

See this question in the RISC OS C Programming FAQ.

Header file naming

On Unix, there's a given hierarchy of header files. So when you install the C library header files (equivalent to UnixLib) they go in /usr/include. So you get files like:

/usr/include/stdio.h
/usr/include/string.h
/usr/include/setjmp.h
/usr/include/time.h
/usr/include/sys/time.h
/usr/include/sys/quota.h
/usr/include/net/ethernet.h

When you install other packages they slot into this structure. For example the GPIB driver library I've been using today lives in:

/usr/include/gpib/ib.h

and if you install the Linux kernel headers you get things like:

/usr/include/linux/adfs_fs.h (the ADFS driver for Linux)
/usr/include/linux/joystick.h

and so on.

The name inside the pointy brackets <> is effectively the path without /usr/include on the front. So

#include <sys/types.h>

refers to

/usr/include/sys/types.h

while

#include <bits/types.h>

refers to

/usr/include/bits/types.h

They're different files, and they have different pathnames (in fact, in glibc on Linux, sys/types.h has a #include <bits/types.h>). In the list above notice there are two time.h files - you'd refer to the first one as plain <time.h> and the second as <sys/time.h>

Of course it's slightly more complicated than that - /usr/include is a system-wide path so you need to be the machine administrator to add things to it. If I'm not administrator I might put some header files in some other directory (/home/theo/myincludes say) and use a -isystem to refer to them.

Personal tools