[0m


PC(1)		    UNIX Programmer's Manual		    PC(1)



[1mNAME
     [0mpc - Pascal compiler

[1mSYNOPSIS
     pc [0m[ option ] ... file ...

[1mDESCRIPTION
     [0m_P_c is an ISO Level 1 Pascal compiler with Berkley exten-
     sions.  Pc shares the Acorn / Norcroft code generation and
     preprocessor with the C compiler. As such it shares many of
     its command line options with cc. Only brief descriptions of
     these options are given here. See _c_c(_1).

     A program may consist of more than one module. Arguments
     whose name end with `.p' are taken to be Pascal source
     modules; they are compiled to object files with the exten-
     sion `.o' in place of `.p'. Arguments ending with `.o' are
     taken to be object modules (possibly generated from another
     language), these are passed to _l_d(_1) along with the compiled
     `.o' files to form an executable _a._o_u_t. If a single Pascal
     program is compiled the `.o' file is deleted in the loading
     phase.

[1mOPTIONS
     [0mThe following options are interpreted by _p_c.  Unrecognised
     options are passed to ld.

     [1m-c   [0mSupress the loading phase of compilation.

     [1m-w   [0mSuppress warning diagnostics.

     [1m-r[0m[_o_p_t_i_o_n_s]
	  Enable or disable a selection of run time checks. The
	  state of the run time check is toggled by each letter
	  specified in options. The following options may be
	  specified (defaults in brackets).

	  [1ma [0mArray bound checking (off).
	  [1mc [0mCase constant for case expression (off).
	  [1mn [0mNil pointer dereferencing (off).
	  [1mr [0mVariable referenced before assigned (off).
	  [1mp [0mAssertion checking (off).
	  [1md [0mDead code checking (on).

     [1m-p   [0mGenerate objects suitable for profiling using prof. See
	  _p_r_o_f(_1).

     [1m-pg  [0mGenerate objects suitable for profiling using gprof.
	  See _g_p_r_o_f(_1).

     [1m-S   [0mLeave assembly language output on corresponding files
	  suffixed `.s'.



Printed 31/1/92         February 16, 1990			1






PC(1)		    UNIX Programmer's Manual		    PC(1)



     [1m-M   [0mUse the macro preprocessor to generate Makefile depen-
	  dencies.

     [1m-E   [0mPreprocess the source code, output to standard output.

     [1m-C   [0mDo not remove comments when preprocessing, use with [1m-E.

     -o [0m_o_u_t_p_u_t
	  Leave the executable in _o_u_t_p_u_t instead of `a.out'.

     [1m-D[0m_n_a_m_e
	  Define preprocessor symbol _n_a_m_e.

     [1m-U[0m_n_a_m_e
	  Undefine preprocessor symbol _n_a_m_e.

     [1m-I[0m_d_i_r
	  Specify search path for `#include' files.

     [1m-help
	  [0mOutput a nmemonic description of command line options.

     [1m-list
	  [0mGenerate a line-numbered compiler listing in a file
	  with extension .lst.

     [1m-iso [0mCompile strictly according to ISO level 1 Pascal (BS
	  6192 : 1982).

[1mLANGUAGE EXTENSIONS
     Identifiers
	  [0mIdentifiers may start with and contain underscores.
	  There is no limit on identifier length and all charac-
	  ters are significant.

     [1mFiles
	  Input [0mand [1moutput [0mneed not appear in the program header.
	  `File of char' and `packed file of char' are treated as
	  equivalent to `text'. Lazy evaluation is performed on
	  files opened for input. In the absence of explicit file
	  bindings (see reset and rewrite in the section on
	  library extensions) external files are bound to a
	  filename corresponding to the file identifier in the
	  current directory, [1minput [0mand [1moutput [0mare bound to
	  /dev/tty. Files are buffered, on a read request from
	  [1minput [0mthe [1moutput [0mbuffer is flushed.

     [1mStrings
	  [0mStrings are blank padded or truncated in expressions
	  and as value parameters to fit the required size.
	  Strings may be of length 1. The null string [1m'' [0mis per-
	  mitted. The [1mpacked [0mattribute may be omitted in a string



Printed 31/1/92         February 16, 1990			2






PC(1)		    UNIX Programmer's Manual		    PC(1)



	  declaration.

	  Pascal strings are zero terminated, the compiler adds
	  one byte to the allocation space of the string and ini-
	  tialises this byte to zero when the string is assigned.
	  Thus Pascal strings may be used in calls to external
	  functions written in C.

	  The predefined type [1mstring [0mis equivalent to the C `char
	  *' and may be used in external calls to C.  Variables
	  of type [1mstring [0mare compatible with Pascal strings and
	  may be used in assignments and expressions and as value
	  parameters. Note that no space is allocated for a vari-
	  able of type string, space must be allocated either by
	  assignment or by explicit allocation using, for exam-
	  ple, _m_a_l_l_o_c(_3).

	  The predefined type [1malpha [0m= packed array[1..10] of char
	  is intended for use with the extended Pascal library,
	  for example, date and time. See the section on library
	  extensions.

     [1mProcedures and functions
	  [0mProcedures may return values, these are declared like
	  functions with the keyword [1mprocedure [0msubstituted for
	  [1mfunction. [0mValue returning procedures may be called in a
	  procedure or function context.  This is intended for
	  use with external functions which return error codes
	  which are not generally checked, for example,
	  _p_u_t_c_h_a_r(_3).

	  Procedures and functions may return records, like
	  pointers these may not be immediatly referenced but
	  must be assigned to a variable.

	  Variadic functions may be declared by placing a [1m.. [0mas
	  the last parameter. Variadic arguments may be accessed
	  using the [1maddress [0mand [1msize [0mfunctions (see the section
	  on library extensions) however the intended purpose is
	  for declaring external variadic functions, for example,
	  _p_r_i_n_t_f(_3).

	  Procedure and functions pointers may be declared, these
	  are declared by placing a `^' before a procedure or
	  function declaration in a type declaration, note that
	  the procedure or function must be given a name and all
	  parameters must be named. Only top level and external
	  procedures or functions may be be assigned to a pro-
	  cedure or function pointer. Procedure and function
	  pointers are intended for use with external procedures
	  or functions which take or return procedure or function
	  pointers, for example, _s_i_g_n_a_l(_3).



Printed 31/1/92         February 16, 1990			3






PC(1)		    UNIX Programmer's Manual		    PC(1)



     [1mExternal objects
	  [0mProcedures, functions and variables may be declared
	  external or global by placing [1mextern; [0mor [1mexternal;
	  [0mafter the declaration (like [1mforward [0mis used for declar-
	  ing forward referenced procedures or functions.  Such
	  objects are taken to be external if there is no defini-
	  tion of the object in the same module and global if
	  there is a definition. Objects declared external use
	  the case of the external declaration identifier. Exter-
	  nal declarations are case sensitive between modules and
	  case insensitive within a single module. The [1mprogram
	  [0mheading may be omitted to create a module containing
	  only procedure and functions and/or variables. No main-
	  line may be given if the program heading is omitted.

	  The recommended way to use external declarations is to
	  create a header file (ending with `.h') containing the
	  external declarations and use the #include mechanism
	  provided by the C preprocessor to include this header
	  in both the module defining the object and the module
	  referencing the object. This insures type correctness
	  between modules. Note that the filename after the
	  #include must be enclosed in double quotes not single
	  quotes.

     [1mType casts
	  [0mFor each pointer, ordinal or file type declared a cast
	  function of the same name is automatically declared
	  which casts a pointer, ordinal or file variable to the
	  declared type.

     [1mConstants
	  [0mConstant expressions may be used in [1mconst [0mdeclarations.
	  The following functions may be used in constant expres-
	  sions if they have constant arguments: shl, shr, uand,
	  uor, uxor, unot, trunc, ord, chr, succ, pred, odd, and
	  undefined.

     [1mDeclarations
	  [0mMultiple Label, Const, Type and Variable declarations
	  sections may be given within a single block. Label,
	  Const, Type, Variable, Procedure and Function declara-
	  tions may occur in any order.

     [1mPredefined types
	  string = ^char [0m- This type is compatible with Pascal
	  strings and is intended for with with external library
	  functions which require a C style string.

	  [1malpha = packed array[1..10] of char [0m- This type is used
	  with the extended library functions [1mtime [0mand [1mdate.




[0mPrinted 31/1/92         February 16, 1990			4






PC(1)		    UNIX Programmer's Manual		    PC(1)



	  [1mpointer [0m- This is a generic pointer type compatible
	  with all other pointer types. It is equivalent to the C
	  void * type.

	  [1mbyte [0m- This is a one byte long signed integer type.

	  [1mshort [0m- This is a half word long signed integer type.

	  [1mword [0m- This is a word long unsigned integer type.

     [1mOperators
	  [0mThe additional operators `&' and `|' are provided.
	  These are functionally identical to [1mand [0mand [1mor.

     Conditional compilation
	  [0mConditional compilation is provided using the #ifdef
	  ... #else ... #endif construct provided by the C
	  preprocessor. Preprocessor symbols may be defined using
	  #define _n_a_m_e.  The use of #if and #define _n_a_m_e _v_a_l_u_e is
	  not advised.

[1mLIBRARY EXTENSIONS
     address(x) : pointer
	  [0mReturns the address of variable access [1mx.

     argc : integer
	  [0mReturns the number of command line arguments to the
	  program including the program name (ie [1margc [0mis always
	  at least 1).

     [1margv(i, a)
	  [0mwhere [1mi [0mis an integer expression in range 0 to [1margc [0mand
	  [1ma [0mis a string variable. If [1ma [0mis of type [1mstring [0mthen the
	  C expression [1margv[i] [0mis assigned directly to [1ma [0m(ie [1ma
	  [0mwill point directly into the [1margv [0marray and should not
	  therefore be modified otherwise the contents of [1margv[i]
	  [0mare copied (possibly blank padded or truncated) to [1ma.

     assert(x[, a])
	  [0mwhere [1mx [0mis a boolean expressions and [1ma [0mis an optional
	  string expression (typically explaining why the asser-
	  tion might of failed). The [1massert [0mcall checks the value
	  of [1mx [0mand if it is [1mfalse [0mgenerates a run time error giv-
	  ing the file and line number where the assertion
	  failed. The reason string [1ma [0mis also printed if given in
	  the [1massert [0mcall. Calls to the [1massert [0mfunction must be
	  enabled with the [1m-rp [0moption on the command line.

     [1mbyte_offset(t, f) : integer
	  t [0mis the name of a record type, [1mf [0mis the name of a
	  field within that record. Returns the offset (in bytes)
	  of field [1mf [0mwithin a variable of record type [1mt.



[0mPrinted 31/1/92         February 16, 1990			5






PC(1)		    UNIX Programmer's Manual		    PC(1)



     [1mcard(s) : integer
	  [0mwhere [1ms [0mis a set expression returns the number of ele-
	  ments in [1ms.

     close(f)
	  [0mwhere [1mf [0mis a file variable close the file bound to [1mf,
	  [0mdeallocates all buffers associated with [1mf [0mand frees [1mf
	  [0mfor reallocation.

     [1mclock : integer
	  [0mreturn the number of milliseconds user time used by
	  this process.

     [1mdate(a)
	  [0mwhere [1ma [0mis a variable of type [1malpha [0massigns the current
	  date to [1ma [0min the form `dd mmm yy'.

     [1mflush(f)
	  [0mflushes any output buffered for file [1mf [0minto its associ-
	  ated file binding.

     [1mhalt [0mstops execution and returns control to the parent pro-
	  cess with a status of 0.

     [1miaddress(x) : integer
	  [0mReturns the address of variable access [1mx [0mas an integer.
	  This is equivalent to [1minteger(address(x)).

     ignore(x)
	  [0mwhere [1mx [0mis an expression of any type. Does nothing.

     [1mlinelimit(f, x)
	  [0mwhere [1mf [0mis a variable of type [1mtext [0mand [1mx [0mis and integer
	  expression. Limits the number of lines of output to
	  file [1mf [0mto [1mx. [0mIf [1mx [0mis less than 0 no limit is imposed.
	  By default no limit is imposed. These limits are
	  ignored by the current release.

     [1mmessage(...)
	  [0mThis is equivalent to [1mwriteln(...) [0mexcept it writes to
	  the unbuffered error stream [1mstderr [0m(file descriptor 2).

     [1mnull [0mDoes nothing.

     [1mrandom(x) : real
	  [0mwhere [1mx [0mis a real expression which is evaluated but
	  otherwise ignored returns a random number between 0.0
	  and 1.0 inclusive.  [1mrandom [0muses a linear congruential
	  random number generator. Successive seeds are generated
	  as (seed * 62605 + 113218009) mod 536870912. The ini-
	  tial seed is 7774755. The `random' numbers generated by
	  this method are not very random, the preferred method



Printed 31/1/92         February 16, 1990			6






PC(1)		    UNIX Programmer's Manual		    PC(1)



	  is to use the external function _r_a_n_d_o_m(_3).

     [1mread(..., a, ...)

     readln(..., a, ...)
	  [0mwhere [1ma [0mis a string variable reads the remainder of the
	  text line into [1ma. [0mThe text line is blank padded or
	  truncated to fit the string. If the variable is of type
	  [1mstring [0mit is assumed that it is pointing to an allo-
	  cated area large enough to hold the current line.

     [1mremove(a)
	  [0mwhere [1ma [0mis a string expression removes the file whose
	  name is [1ma [0m(with trailing blanks removed).

     [1mreset(f, a)
	  [0mwhere [1mf [0mis a file variable and [1ma [0mis a string expression
	  associates the filename [1mf [0mwith the file variable and
	  opens that file for reading. Note that there is no way
	  of detecting an error opening a file (eg. file not
	  found). To do this use the external function _f_o_p_e_n(_3)
	  or _s_t_a_t(_2).

     [1mrewrite(f, a)
	  [0mSimilarly to [1mreset, [0mthe two argument form of rewrite
	  allows a filename to be bound to a file variable except
	  the file is opened for writing instead of reading.

     [1mseed(x) : integer
	  [0mwhere [1mx [0mis an integer expression sets the current ran-
	  dom number generator seed to [1mx [0mand returns the value of
	  the previous seed.

     [1mshl(x1, x2) : integer
	  [0mwhere [1mx1 [0mand [1mx2 [0mare integers returns [1mx1 [0mshifted left [1mx2
	  [0mtimes. This is equivalent to [1mx1 << x2 [0min C.

     [1mshr(x1, x2) : integer
	  [0mwhere [1mx1 [0mand [1mx2 [0mare integers returns [1mx1 [0mshifted right
	  [1mx2 [0mtimes. This is equivalent to [1mx1 >> x2 [0min C.

     [1msize(x) : integer
	  [0mwhere [1mx [0mis a variable access returns the size of vari-
	  able access [1mx [0min bytes.

     [1mstlimit(x)
	  [0mwhere [1mx [0mis an integer expression limits the number of
	  statements that may be executed by the current program.
	  By default no limit is imposed. This limit is ignored
	  by the current release.

     [1msysclock : integer



[0mPrinted 31/1/92         February 16, 1990			7






PC(1)		    UNIX Programmer's Manual		    PC(1)



	  returns the number of milliseconds system time used by
	  this process.

     [1mtime(a)
	  [0mwhere [1ma [0mis a variable of type [1malpha [0massigns the current
	  local time to [1ma [0min the form `hh:mm:ss'.

     [1muand(x1, x2) : integer
	  [0mwhere [1mx1 [0mand [1mx2 [0mare integer returns the bitwise and of
	  [1mx1 [0mand [1mx2. [0mThis is equivalent to [1mx1 & x2

     uor(x1, x2) : integer
	  [0mwhere [1mx1 [0mand [1mx2 [0mare integer returns the bitwise or of
	  [1mx1 [0mand [1mx2. [0mThis is equivalent to [1mx1 | x2 [0min C.

     [1mundefined(x) : boolean
	  [0mwhere [1mx [0mis a real expression returns [1mfalse.

     unot(x) : integer
	  [0mwhere [1mx [0mis integer returns the bitwise negation of [1mx.
	  [0mThis is equivalent to [1m~x [0min C.

     [1muxor(x1, x2) : integer
	  [0mwhere [1mx1 [0mand [1mx2 [0mare integer returns the bitwise
	  exclusive or of [1mx1 [0mand [1mx2. [0mThis is equivalent to [1mx1 ^
	  x2 [0min C.

     [1mwrite(..., x [: n] <mode>, ...)

     writeln(..., x [: n] <mode>, ...)
	  [0mwhere [1mx [0mis a boolean, character or integer expression,
	  n is an optional field width and <mode> is one of [1mhex
	  [0mor [1moct [0mwrites the expression x in hexadecimal or octal
	  notation respectively.

     [1mwallclock : integer
	  [0mreturns the time in seconds since 00:00:00 GMT, January
	  1, 1970.

[1mDIAGNOSTICS
     [0mThe diagnostics produced by the Pascal compiler are intended
     to be self explanatory. Occasional messages may be produced
     by the loader. Other messages may be produced by C specific
     parts of the Acorn / Norcroft code generator.

[1mFILES
     [0mfile.p		      Pascal source file
     file.o		      object file
     a.out		      executable
     /usr/bin/pc	      Pascal compiler
     /usr/lib/libpc.a	      Pascal library




Printed 31/1/92         February 16, 1990			8






PC(1)		    UNIX Programmer's Manual		    PC(1)



[1mSEE ALSO
     [0mBSI Computer Programming Language Pascal (BS 6192 : 1982)
     Pascal User Manual and Report (3rd edition)
     Berkley Pascal User's Manual

[1mBUGS
     [0mGoto into block is not detected and may cause a core dump if
     the block at which the goto is directed is not reached by
     any other means.

     In [1m-iso [0mmode applied occurences are not detected (this is
     normal behaviour for Berkley Pascal).

     The actual parameters corresponding to formal parameters
     that occur in a single conformant array parameter specifica-
     tion may possess different types as long as they are con-
     formable with the formal parameter type.

     [1mremove [0mtakes an argument of type [1malpha, [0mnot a string and
     does not strip trailing spaces from its argument.

     [1maddress [0mreturns pointer to the type of its argument instead
     of the generic type [1mpointer.

     undefined [0mis declared in one place within the Pascal com-
     piler as a function and in another place as a procedure,
     therefore it can be used in neither procedure or function
     contexts.

     This is a Beta version of _p_c.  The compiler is know to
     behave badly when given syntactically incorrect source code.
     Support for _d_b_x(1) is also incomplete, although the compiler
     will recognise the [1m-g [0moption if it is used it will fre-
     quently fail with an internal error on legal code.  See the
     release notice supplied with the system for a more complete
     description of known problem areas.



















Printed 31/1/92         February 16, 1990			9



[0m