<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<TITLE>ArmBob's preprocessor</TITLE>
<LINK REL=STYLESHEET HREF="style.css" TYPE="text/css">
</HEAD>
<BODY style="margin-left: 6em;">
<H2>ArmBob   - Preprocessor Directives</H2>
<P>

Preprocessing will be familiar to C and C++ programmers.
ArmBob source code is first  transformed by an inbuilt
preprocessor before being compiled into bytecode. The commands understood by it
begin with the character #, and they must not be preceded by anything else on the line,
even blank spaces. The commands are:
<PRE>
#include full_pathname_of_file
</PRE>
which causes the output from preprocessing the file specified by 
<CODE>full_pathname_of_file</CODE>
to be inserted at this point. This file may itself contain <CODE>#include</CODE> commands, and so on
to a depth of 8. The specification of the file may be any valid Risc OS expression, 
such as <CODE>MyPath:myfile</CODE> or <CODE>&lt;X$Dir&gt;.test</CODE>. Note that the conventional notations of C, 
like <CODE>&lt;stdio.h&gt;</CODE> or <CODE>"myfile.c"</CODE> are not supported. 
<PRE>
#define symbol expr
#define mymacro(x,y, .. ) body_of_macro
</PRE>
causes <CODE>symbol</CODE> to be replaced by the expression <CODE>expr</CODE> in subsequent text (and that
includes <CODE>#include</CODE>d text). Similarly expressions of the form 
<CODE>mymacro( expr1, expr2, ... )</CODE>
are replaced by instances of <CODE>body_of_macro</CODE> but with the variables <CODE>x,y, ..</CODE> replaced by
the expressions <CODE>expr1, expr2,</CODE> and so on. For a precise description of the semantics of
vague words like <EM>replaced by</EM> see the reference section of Kernighan and Ritchie's
classic text <B>The C Programming Language</B>. Macro names should begin with a letter
of the alphabet, or an underscore (_), and be followed by letters of the alphabet,
underscores or digits. A macro cannot have more than 16 parameters.

<PRE>
##  
</PRE>
In the body of a macro the symbol <CODE>##</CODE> is replaced by nothing. This is useful for 
concatenating strings. So, for example,
<PRE>
         #define join(a,b) a##b
</PRE>
will convert <CODE>join(file,1)</CODE> to <CODE>file1</CODE>.
<PRE>
#ifdef symbol
.......
#endif
</PRE>
The text <CODE>....</CODE> will be omitted if <CODE>symbol</CODE> is not currently <CODE>#define</CODE>d as something.
<PRE>
#ifndef symbol
......
#endif
</PRE>
The text <CODE>....</CODE> will be omitted if <CODE>symbol</CODE> is currently <CODE>#define</CODE>d as something.
<PRE>
#else
</PRE>
is used as you would expect to give alternative blocks:
<PRE>
#ifdef
......
#else
......
#endif
</PRE>
or
<PRE>
#ifndef
......
#else
......
#endif
</PRE>
Preprocessed files should be less than 32000 characters in size. If anybody finds this
irksome, that can be remedied.
<HR>
<A HREF="index.html">Back to the index</A>
</BODY>
</HTML>





