HP SunSoft Pascal 4.0 Bedienungsanleitung

Stöbern Sie online oder laden Sie Bedienungsanleitung nach Software HP SunSoft Pascal 4.0 herunter. HP SunSoft Pascal 4.0 User's Manual Benutzerhandbuch

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 333
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen

Inhaltsverzeichnis

Seite 1 - Pascal 4.0 User’s Guide

Pascal 4.0 User’s GuidePart No.: 802-2943-10Revision A, November 1995A Sun Microsystems, Inc. Business2550 Garcia AvenueMountain View, CA 94043U.S.A.

Seite 2

x Pascal 4.0 User’s GuideFunction Return Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130Parameters That Are Pointers to Procedur

Seite 3 - Contents

76 Pascal 4.0 User’s Guide5Using Program UnitsThe program unit is the source program with the program header. It has thefollowing syntax:<program

Seite 4

Separate Compilation 775Compiling without the -xl OptionThere are three ways of sharing variables and routines across units when youcompile your progr

Seite 5 - Contents v

78 Pascal 4.0 User’s Guide5Using extern Option to Share RoutinesIf a program or module calls a procedure not defined in that unit, you mustdeclare it w

Seite 6

Separate Compilation 795The program unit, inc_prog.p,which includes the fileinclude.hprogram inc_prog;#include "include.h"begin { program bod

Seite 7 - Contents vii

80 Pascal 4.0 User’s Guide5Using the -xl OptionWhen you use the –xl option, variables and top-level procedures andfunctions declared in the program un

Seite 8

Separate Compilation 815The program unit,pubvar_prog.p, which declaresglobal as publicprogram pubvar_prog;public var global: integer;procedure proc

Seite 9 - Contents ix

82 Pascal 4.0 User’s Guide5Using the define Variable AttributeThis example makes global public using the define attribute of the variabledeclaration.Th

Seite 10

Separate Compilation 835Using the define DeclarationThis example defines global in the module defvar_mod2 using the definedeclaration. The advantage o

Seite 11 - Contents xi

84 Pascal 4.0 User’s Guide5Using include FilesIn the following example, the extern declaration for the variable global is inthe include file, inc_prog2

Seite 12

Separate Compilation 855The program unit, inc_prog2.p program inc_prog2;%include "include2.h";procedure proc; extern;begin global := 1;

Seite 13 - Contents xiii

Contents xiGeneral Parameter-Passing in FORTRAN and Pascal. . . . . . . . 167Procedure Calls: FORTRAN-Pascal. . . . . . . . . . . . . . . . . . . . .

Seite 14

86 Pascal 4.0 User’s Guide5Using externIn the previous example, the extern definition for variables is put into aninclude file and then shared. You can

Seite 15

Separate Compilation 875Sharing Declarations in Multiple UnitsUsing extern and external directives for procedure and functiondeclarations, you can opt

Seite 16

88 Pascal 4.0 User’s Guide5For routines declared extern fortran or external fortran, the changesin the calling sequence are as follows:• For value par

Seite 17

89The C–Pascal Interface6This chapter describes how to mix C and Pascal modules in the same program.It contains the following sections:The examples in

Seite 18

90 Pascal 4.0 User’s Guide6The -c option produces an unlinked object file. The -calign option causespc to use C-like data formats for aggregate object

Seite 19 - Installation

The C–Pascal Interface 916Precautions with Compatible TypesThis section describes the precautions you should take when working withcompatible types.Th

Seite 20 - Organization

92 Pascal 4.0 User’s Guide6Array IndexesPascal array indexes can start at any integer; C array indexes always start atzero.Aggregate TypesAggregate ty

Seite 21

The C–Pascal Interface 936Pascal Set TypesIn Pascal, a set type is implemented as a bit vector, which is similar to a Cshort-word array, where each sh

Seite 22 - Related Documentation

94 Pascal 4.0 User’s Guide6Variable ParametersPascal passes all variable parameters by reference, which C can do, too.The C main program,SampMain.c.

Seite 23 - Other Related Documentation

The C–Pascal Interface 956Simple Types without –xlWithout -xl, simple types match, as in the following example:The Pascal procedure,SimVar.pprocedure

Seite 24

xii Pascal 4.0 User’s GuideThe scalar Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211Procedure and Function Type Errors.

Seite 25 - Introduction

96 Pascal 4.0 User’s Guide6Simple Types with –xlWith the -xl option, the Pascal real must be paired with a C float, and thePascal integer must be pair

Seite 26 - Compatibility

The C–Pascal Interface 976Fixed ArraysFor a fixed array parameter, pass the same type and size by reference, asshown in the following example:The C mai

Seite 27 - Native Language Support

98 Pascal 4.0 User’s Guide6Although it does not apply in this example, arrays of aggregates in Pascalhave, by default, a size that is always a multipl

Seite 28 - Internationalization

The C–Pascal Interface 996The Pascal procedure,DaysOfWeek.ptypeTDay= array [0..8] of char;TWeek = array [0..6] of day;TYear = array [0..51] of week;pr

Seite 29 - Licensing

100 Pascal 4.0 User’s Guide6The univ ArraysYou can pass any size array to a Pascal procedure expecting a univ array,although there is no special gain

Seite 30 - 6 Pascal 4.0 User’s Guide

The C–Pascal Interface 1016Conformant ArraysFor single-dimension conformant arrays, pass upper and lower bounds, placedafter the declared parameter li

Seite 31 - Pascal Programs

102 Pascal 4.0 User’s Guide6Examples of single-dimension, multidimension, and array-of-characterconformant arrays follow. Conformant arrays are inclu

Seite 32 - Compiling the Program

The C–Pascal Interface 1036Example 2: Multi-Dimension ArrayThe Pascal procedure,RealCA.p. Pascal passes lowbound, high bound, and elementwidth.proced

Seite 33 - Renaming the Executable File

104 Pascal 4.0 User’s Guide6If wc is the width of the smallest element, as determined by sizeof(), thenthe width of the next largest element is the nu

Seite 34 - An Interactive Pascal Program

The C–Pascal Interface 1056Records and StructuresIn most cases, a Pascal record describes the same objects as its C structureequivalent, provided that

Seite 35 - Redirecting I/O

Contents xiiiAn Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227Sample Translation of an XView Function to Pa

Seite 36

106 Pascal 4.0 User’s Guide6The record in the example above has, by default, the same size and alignmentas the equivalent C record. Some records, tho

Seite 37 - Where Did My Program Fail?

The C–Pascal Interface 1076Consider this example:The Pascal routine,DayWeather.ptype TDayWeather = recordTDay: array [0..8] of char;TWeather: array

Seite 38

108 Pascal 4.0 User’s Guide6When you compile the Pascal routine without using the -calign option, theprogram does not work correctly.Variant RecordsC

Seite 39 - Using the -g Option

The C–Pascal Interface 1096The C main program,VarRecMain.c#include <stdio.h> struct vlr { char tag; union { struct {

Seite 40

110 Pascal 4.0 User’s Guide6Pascal Set TypeIn Pascal, a set type is implemented as a bit vector, which is similar to a Cshort-word array. Direct acce

Seite 41 - The Pascal Compiler

The C–Pascal Interface 1116Pascal intset TypeThe Pascal intset type is predefined as set of [0..127]. A variable ofthis type takes 16 bytes of storage

Seite 42 - Compile and Link Sequence

112 Pascal 4.0 User’s Guide6Value ParametersThere are three types of value parameters in Pascal.Simple Types without –xlWithout –xl, simple types matc

Seite 43 - Language Preprocessor

The C–Pascal Interface 1136If no function prototype is provided for SimVal in SimValMain.c, thensr:shortreal must be changed to sr:real in SimVal.p.

Seite 44

114 Pascal 4.0 User’s Guide6ArraysSince C cannot pass arrays by value, it cannot pass strings of characters, fixedarrays, or univ arrays by value.Confo

Seite 45

The C–Pascal Interface 1156Function Return ValuesFunction return values match types the same as with parameters, and theypass in much the same way.Sim

Seite 46

xiv Pascal 4.0 User’s Guide

Seite 47

116 Pascal 4.0 User’s Guide6Input and OutputIf your C main program calls a Pascal procedure that does I/O, then includethe following code in the C mai

Seite 48 - –Bbinding

The C–Pascal Interface 1176Procedure Calls: Pascal–CThis section parallels the section, “Procedure Calls: C–Pascal” on page 93.Earlier comments and re

Seite 49 - {$b1} Line buffering

118 Pascal 4.0 User’s Guide6Strings of CharactersThe alfa and string types pass simply; varying strings are morecomplicated. All pass by reference.Th

Seite 50 - 26 Pascal 4.0 User’s Guide

The C–Pascal Interface 1196The C function, StrVar.c #include <string.h>struct TVarLenStr { int nbytes; char a[26];};void StrVar(char *s10,

Seite 51 - –Dname[=def]

120 Pascal 4.0 User’s Guide6Avoid constructs that rely on strings being in static variable storage. Forexample, you could use mktemp(3) in Pascal as

Seite 52 - 28 Pascal 4.0 User’s Guide

The C–Pascal Interface 1216Fixed ArraysFor a fixed-array parameter, pass the same type and size, as in this example:The -calign option is not needed fo

Seite 53 - –fround=r

122 Pascal 4.0 User’s Guide6The univ ArraysThe univ arrays that are in, out, in out, or var parameters pass byreference.Here is an example:The C funct

Seite 54 - –ftrap=t

The C–Pascal Interface 1236The -calign option is not needed for this example, but may be necessary ifthe array parameter is an array of aggregates.Con

Seite 55 - The Pascal Compiler 31

124 Pascal 4.0 User’s Guide6The -calign option is not needed for this example, but may be necessary ifthe array parameter is an array of aggregates.Re

Seite 56 - -keeptmp

The C–Pascal Interface 1256Variant RecordsC equivalents of variant records can sometimes be constructed, although thereis some variation with the arch

Seite 57 - -Ldirectory

xvFiguresFigure 3-1 Organization of Pascal Compilation. . . . . . . . . . . . . . . . . . . . . . 19Figure 3-2 Options in Program Text . . . . . . . .

Seite 58 - –misalign

126 Pascal 4.0 User’s Guide6Following are some examples:The C function, VarRec.c struct vlr { char tag; union {struct { char ch1, ch2;} a_var

Seite 59 - -noqueue

The C–Pascal Interface 1276The -calign option is not needed in the previous example, but may benecessary if the record contains aggregates.Non-Pascal

Seite 60 - –O[level]

128 Pascal 4.0 User’s Guide6See this example:The C function, NonPas.c. Inthe function for_C, s is apointer (declared var in theprocedure declaration)

Seite 61 - The Pascal Compiler 37

The C–Pascal Interface 1296Value ParametersIn general, Pascal passes value parameters in registers or on the stack,widening to a full word if necessar

Seite 62 - –o filename

130 Pascal 4.0 User’s Guide6Function Return ValuesFunction return values match types in the same manner as with parameters,and they pass in much the s

Seite 63 - –pic,-Kpic and –PIC, -KPIC

The C–Pascal Interface 1316Parameters That Are Pointers to ProceduresPascal has a special type that is a pointer to a procedure. A variable of thisty

Seite 64 - –Qproduce

132 Pascal 4.0 User’s Guide6Procedures and Functions as ParametersIt is probably clearer to pass a pointer to a procedure than to pass theprocedure na

Seite 65 - -R path[

The C–Pascal Interface 1336functions can be passed to other languages as arguments, the static links for allprocedure or function arguments are placed

Seite 66 - 42 Pascal 4.0 User’s Guide

134 Pascal 4.0 User’s Guide6File-Passing Between Pascal and CYou can pass a file pointer from Pascal to C, then have C do the I/O, as in:The commands t

Seite 67 - Examples:

The C–Pascal Interface 1356The commands to compile andexecute UseFilePtc.c andUseFilePtrMain.phostname% cc -c UseFilePtr.chostname% pc UseFilePtr.o Us

Seite 68

xvi Pascal 4.0 User’s Guide

Seite 69

136 Pascal 4.0 User’s Guide6

Seite 70 - 46 Pascal 4.0 User’s Guide

137The C++–Pascal Interface7This chapter describes how to mix C++ and Pascal modules in the sameprogram. It contains the following sections:Sample In

Seite 71 - –temp=dir

138 Pascal 4.0 User’s Guide7Compatibility of Types for C++ and PascalTable 6-1 and Table 6-2 on page 90 list the default sizes and alignments ofcompat

Seite 72

The C++–Pascal Interface 1397Arguments Passed by ReferenceC++ arguments can be passed by reference. This section describes how theywork with Pascal.T

Seite 73 - The Pascal Compiler 49

140 Pascal 4.0 User’s Guide7Simple Types without the -xl OptionWithout the -xl option, simple types match, as in the following example:The Pascal proc

Seite 74 - 50 Pascal 4.0 User’s Guide

The C++–Pascal Interface 1417Simple Types with the -xl OptionWith the -xl option, the Pascal real must be paired with a C++ float; thePascal integer

Seite 75

142 Pascal 4.0 User’s Guide7Strings of CharactersThe C++ counterpart to the Pascal alfa and string types are arrays. The C++counterpart to the Pascal

Seite 76 - v7 or v8 machine

The C++–Pascal Interface 1437The C++ main program,StrRefMain.cc#include <stdio.h>#include <string.h> struct TVarLenStr { int NBytes;

Seite 77 - • s1/l1/a1:s2/l2/a2:s3/l3/a3

144 Pascal 4.0 User’s Guide7Fixed ArraysThe Pascal procedure,FixVec.ptype TVec = array [0..8] of integer;procedure FixVec ( var V: TVec; var Sum: i

Seite 78 - -xchip=c

The C++–Pascal Interface 1457Although it does not apply to this example, arrays of aggregates in Pascalhave, by default, a size that is a multiple of

Seite 79

xviiTablesTable 3-1 File Name Suffixes Recognized by Pascal . . . . . . . . . . . . . . . . . 20Table 3-2 Options That Can Be Passed in Program Text

Seite 80 - -xlibmil

146 Pascal 4.0 User’s Guide7Records and StructuresA Pascal record of an integer and a character string matches a C++ structure ofthe same constructs,

Seite 81 - The Pascal Compiler 57

The C++–Pascal Interface 1477The C++ main program,StruChrMain.cc#include <stdio.h>#include <string.h> struct TVarLenStr { int NBytes;

Seite 82 - -xprofile=p

148 Pascal 4.0 User’s Guide7Consider this example:The Pascal procedure,DayWeather.ptype TDayWeather = record TDay: array [0..8] of char; TWeat

Seite 83

The C++–Pascal Interface 1497The C++ main program,DayWeatherMain.cc#include <stdio.h>#include <string.h> struct TDayRec { char TDay[9]

Seite 84 - -xregs=r

150 Pascal 4.0 User’s Guide7Arguments Passed by ValueC++ arguments can be passed by value. In this section, we describe how theywork with Pascal.When

Seite 85 - The Pascal Compiler 61

The C++–Pascal Interface 1517Simple Types without the -xl OptionWithout the -xl option, simple types match, as in the following example:The Pascal pro

Seite 86 - -xtarget=t

152 Pascal 4.0 User’s Guide7Function Return ValuesFunction return values match types in the same manner as with parameters.They pass in much the same

Seite 87

The C++–Pascal Interface 1537Simple TypesSimple types pass in a straightforward way, as in the following example:The Pascal function,RetReal.pfunction

Seite 88

154 Pascal 4.0 User’s Guide7Type shortrealInput and OutputThe Pascal function,RetShortReal.pfunction RetShortReal (r: shortreal): shortreal;begin Ret

Seite 89

The C++–Pascal Interface 1557Procedure Calls: Pascal–C++A Pascal main program can also call C++ functions. The following examplesshow you how to pass

Seite 90

xviii Pascal 4.0 User’s GuideTable 10-1 C Declarations to Pascal Declarations . . . . . . . . . . . . . . . . . . . . 228Table 11-1 Contents of Math L

Seite 91 - Management

156 Pascal 4.0 User’s Guide7Simple Types Passed by ReferenceSimple types pass in a straightforward manner, as follows:The C++ function, SimRef.cc exte

Seite 92

The C++–Pascal Interface 1577Arguments Passed by ValuePascal arguments can also be passed by value. Here is how they work withC++.The Pascal main pro

Seite 93 - Compiling with Units

158 Pascal 4.0 User’s Guide7Simple TypesSimple types match with value parameters. See the following example:The C++ function, SimVal.cc extern "

Seite 94 - Using Units and Header Files

The C++–Pascal Interface 1597Function Return ValuesFunction return values match types in the same manner as with parameters.They pass in much the same

Seite 95

160 Pascal 4.0 User’s Guide7The following example shows how to pass simple types:The C++ function, RetReal.cc extern "C"double RetReal (doub

Seite 96

The C++–Pascal Interface 1617Global Variables in C++ and PascalIf the types are compatible, a global variable can be shared between C++ andPascal. Se

Seite 97

162 Pascal 4.0 User’s Guide7Pascal File Pointers to C++You can pass a file pointer from Pascal to C++, then have C++ do the I/O. Seethis example.The C

Seite 98 - Libraries

163The FORTRAN–Pascal Interface8This chapter describes how to mix FORTRAN 77 and Pascal modules in thesame program. It contains the following section

Seite 99 - Separate Compilation

164 Pascal 4.0 User’s Guide8Specify –lpfc on the command-line before –lpc. For example:The -c option to pc produces an unlinked object file.When you c

Seite 100 - • include files

The FORTRAN–Pascal Interface 1658Table 8-2 lists the default sizes and alignments of compatible types forFORTRAN and Pascal with the -xl option:Precau

Seite 101 - Sharing Public Variables

xixPrefaceThis manual describes the Pascal 4.0 compiler from SunSoft™. The purpose ofthis manual is to help you begin writing and compiling Pascal pr

Seite 102

166 Pascal 4.0 User’s Guide8Character StringsThere are some precautions to take with character strings regarding the nullbyte, passing by value, and s

Seite 103

The FORTRAN–Pascal Interface 1678Pascal Set TypesIn Pascal, a set type is implemented as a bit vector, which is similar to aFORTRAN 16-bit word. Dire

Seite 104 - Using the -xl Option

168 Pascal 4.0 User’s Guide8Procedure Calls: FORTRAN-PascalHere are examples of how a FORTRAN main program calls a Pascal procedure.Variable Parameter

Seite 105

The FORTRAN–Pascal Interface 1698See the following example:The Pascal procedure,SimVar.pprocedure simvar_(var t, f: boolean; var c: char;

Seite 106

170 Pascal 4.0 User’s Guide8Simple Types with the –xl OptionWhen you pass the -xl option, the Pascal data type real must be paired witha FORTRAN data

Seite 107 - Using the define Declaration

The FORTRAN–Pascal Interface 1718Fixed ArraysFor a fixed array parameter, pass the same type and size by reference, asshown in the following example:Th

Seite 108 - Using include Files

172 Pascal 4.0 User’s Guide8The univ ArraysYou can pass any size array to a Pascal procedure expecting a univ array, butthere is no advantage in doing

Seite 109 - , inc_mod2.p module inc_mod2;

The FORTRAN–Pascal Interface 1738Conformant ArraysFor conformant arrays, with single-dimension array, pass upper and lowerbounds, placed after the dec

Seite 110 - Using extern

174 Pascal 4.0 User’s Guide8Example 1: Single-Dimension ArrayExample 2: Array of CharactersThe Pascal procedure,IntCA.p. Pascal passes thebounds by v

Seite 111

The FORTRAN–Pascal Interface 1758Records and StructuresIn most cases, a Pascal record describes the same objects as its FORTRANstructure equivalent, p

Seite 112 - 88 Pascal 4.0 User’s Guide

PleaseRecycle 1995 Sun Microsystems, Inc. 2550 Garcia Avenue, Mountain View, California 94043-1100 U.S.A.All rights reserved. This product or documen

Seite 113 - The C–Pascal Interface

xx Pascal 4.0 User’s GuideAudienceThis guide was prepared for software engineers who write Pascal programs ona SPARCstation. It assumes you are famil

Seite 114

176 Pascal 4.0 User’s Guide8A Pascal record of an integer and a character string matches a FORTRANstructure of the same. Consider these examples:The

Seite 115 - Character Strings

The FORTRAN–Pascal Interface 1778Variant RecordsFORTRAN equivalents of variant records can sometimes be constructed,although there is some variation w

Seite 116 - Incompatibilities

178 Pascal 4.0 User’s Guide8The FORTRAN main program,VarRecmain.f. The variableALIGN is integer*2, and isneeded to match the Pascalvariant record lay

Seite 117 - Procedure Calls: C–Pascal

The FORTRAN–Pascal Interface 1798Pascal Set TypeThe Pascal set type is incompatible with FORTRAN.Pascalintset TypeThe Pascal intset type is predefined

Seite 118 - Variable Parameters

180 Pascal 4.0 User’s Guide8Value ParametersIn general, Pascal passes value parameters on the stack.Simple Types without the –xl OptionWithout the -xl

Seite 119 - Simple Types without –xl

The FORTRAN–Pascal Interface 1818See the following example:The Pascal procedure,SimVal.p. t, f, c, i, r, and sare value parameters.procedure simval_(t

Seite 120 - Strings of Characters

182 Pascal 4.0 User’s Guide8Simple Types with the –xl OptionWith the -xl option, match Pascal real with FORTRAN real and Pascalinteger with FORTRAN in

Seite 121 - Fixed Arrays

The FORTRAN–Pascal Interface 1838PointersPointers are easy to pass, as shown in the following example:Pascal procedure, ChrCAx.p procedure chrca_ ( a:

Seite 122

184 Pascal 4.0 User’s Guide8Function Return ValuesFunction return values match types the same as with parameters, and theypass in much the same way.

Seite 123

The FORTRAN–Pascal Interface 1858Simple TypesThe simple types pass in a straightforward way, as follows:TypeshortrealThere is no problem with returnin

Seite 124 - The univ Arrays

Preface xxi• Appendix B, “Error Messages,” lists all the error messages the compilerproduces.This guide concludes with an index.Conventions Used in T

Seite 125 - Conformant Arrays

186 Pascal 4.0 User’s Guide8Variable ParametersPascal passes all var parameters by reference, the FORTRAN default.Simple TypesSimple types pass in a s

Seite 126

The FORTRAN–Pascal Interface 1878Strings of CharactersThe alfa and string types pass simply; varying strings are a little tricky. Allpass by referenc

Seite 127

188 Pascal 4.0 User’s Guide8The FORTRAN subroutine,StrVar.f subroutine StrVar ( s10, s80, vls ) character s10*10, s80*80 struct

Seite 128

The FORTRAN–Pascal Interface 1898Character Dummy ArgumentsWhen you call FORTRAN 77 routines with character dummy arguments fromPascal programs—that is

Seite 129 - Records and Structures

190 Pascal 4.0 User’s Guide8The following example illustrates this method:The Pascal program, sun.pas program Test(input,output);var s : string;proc

Seite 130

The FORTRAN–Pascal Interface 1918Fixed ArraysFor a fixed-array parameter, pass the same type and size by reference:The FORTRAN subroutine,FixVec.f

Seite 131 - Consider this example:

192 Pascal 4.0 User’s Guide8The univ ArraysThe univ arrays that are in, out, in out, or var parameters pass byreference.The FORTRAN subroutine,UniVec.

Seite 132 - Variant Records

The FORTRAN–Pascal Interface 1938Conformant ArraysPascal-conformant array parameters are not compatible if Pascal callsFORTRAN.The commands to compile

Seite 133

194 Pascal 4.0 User’s Guide8Records and StructuresRecords and structures pass as follows:The FORTRAN subroutine,StruChr.f subroutine StruChr (

Seite 134 - Pascal Set Type

The FORTRAN–Pascal Interface 1958Variant RecordsYou can construct FORTRAN equivalents of variant records. There is somevariation with architecture, a

Seite 135 - Pascal intset Type

xxii Pascal 4.0 User’s GuideShell Prompts in Command ExamplesThe following table shows the default system prompt and superuser promptfor the C shell,

Seite 136 - Value Parameters

196 Pascal 4.0 User’s Guide8Chapter 6, “The C–Pascal Interface,” has an example that matches thefollowing example.The FORTRAN subroutine,VarRec.f. Th

Seite 137

The FORTRAN–Pascal Interface 1978Value ParametersWith external fortran on the procedure statement, Pascal passes valueparameters as FORTRAN expects th

Seite 138

198 Pascal 4.0 User’s Guide8Simple TypesWith external fortran, the procedure name in the procedure statementand in the call must be in lowercase, with

Seite 139 - Function Return Values

The FORTRAN–Pascal Interface 1998The Pascal main program,SimValmain.pprogram SimVal(output);var t: boolean := true; f: boolean := false; c: c

Seite 140 - Input and Output

200 Pascal 4.0 User’s Guide8PointersPointers are easy to pass, as shown in the following example:The FORTRAN subroutine,PassPtr.f. In the FORTRANsubr

Seite 141 - Procedure Calls: Pascal–C

The FORTRAN–Pascal Interface 2018Function Return ValuesFunction return values match types the same as with parameters, and theypass in much the same w

Seite 142

202 Pascal 4.0 User’s Guide8Type shortrealYou can return a shortreal function value between Pascal and FORTRAN.Pass it exactly as in the previous exam

Seite 143

The FORTRAN–Pascal Interface 2038If the procedure is not a top-level procedure, then you do not deal with how topass it, because that requires allowin

Seite 144

204 Pascal 4.0 User’s Guide8Routines in other languages can be passed to Pascal; a dummy argument mustbe passed in the position normally occupied by t

Seite 145

205Error Diagnostics9This chapter discusses the errors you may come across while writing softwareprograms with Pascal. It contains the following sect

Seite 146

Preface xxiiiREADME FilesThe README default directory is: /opt/SUNWspro/READMEs.This directory contains the following files:• A Pascal 4.0 README, call

Seite 147

206 Pascal 4.0 User’s Guide9Most nonprinting characters in your input are also illegal, except in characterconstants and character strings. Except fo

Seite 148

Error Diagnostics 2079Replacements, Insertions, and DeletionsWhen Pascal encounters a syntax error in the input text, the compiler invokesan error rec

Seite 149

208 Pascal 4.0 User’s Guide9Undefined or Improper IdentifiersIf an identifier is encountered in the input but is undeclared, the error recoverymechanism

Seite 150 - Following are some examples:

Error Diagnostics 2099Expected and Unexpected End-of-fileIf pc finds a complete program, but there is more (noncomment) text in theinput file, then it in

Seite 151 - Non-Pascal Procedures

210 Pascal 4.0 User’s Guide9Compiler Semantic ErrorsThe following sections explain the typical formats and terminology used inPascal error messages.Fo

Seite 152 - See this example:

Error Diagnostics 2119Thus, if you try to assign an integer value to a char variable, you receive adiagnostic as follows:In this case, one error produ

Seite 153

212 Pascal 4.0 User’s Guide9Scalar Error MessagesError messages stating that scalar (user-defined) types cannot be read from andwritten to files are oft

Seite 154

Error Diagnostics 2139This program generates the following error messages:program expr_example(output);var a: set of char; b: Boolean; c: (re

Seite 155

214 Pascal 4.0 User’s Guide9Type EquivalenceThe Pascal compiler produces several diagnostics that generate the followingmessage:non-equivalent typesIn

Seite 156

Error Diagnostics 2159To make the assignment statement work, you must declare a type and use it todeclare the variables, as follows:Alternatively, you

Seite 157

xxiv Pascal 4.0 User’s GuideNumerical Computation Guide X (AnswerBook)README X (CD-ROM)What Every Scientist Should Know About Floating-Point Arithmeti

Seite 158

216 Pascal 4.0 User’s Guide9A statement is considered to be reachable if there is a potential path of control,even if it cannot be taken. Thus, no di

Seite 159

Error Diagnostics 2179If you declare a label but never use it, Pascal gives you a warning. This is trueeven for a label declared in global scope.Comp

Seite 160 - 136 Pascal 4.0 User’s Guide

218 Pascal 4.0 User’s Guide9<filename> : Bad data found on enumerated read<filename> : Bad data found on integer read<filename> : Bad d

Seite 161 - The C++–Pascal Interface

Error Diagnostics 2199Argument to argv of <number> is out of rangeAssertion #<number> failed: <assertion message>Cannot close null f

Seite 162 - Procedure Calls: C++–Pascal

220 Pascal 4.0 User’s Guide9Pointer value (<number>) out of legal rangeRan out of memoryRange lower bound of <number> out of set boundsRan

Seite 163 - Arguments Passed by Reference

221The XView Toolkit10This chapter introduces the XView programmer’s toolkit, a part of the XViewapplication programmer’s interface (API). It assumes

Seite 164

222 Pascal 4.0 User’s Guide10ToolsThis kit is a collection of functions. The runtime system is based on eachapplication having access to a server-bas

Seite 165

The XView Toolkit 22310with the root being the class from which all others are descended. In theXView toolkit, the root is the class Generic Object,

Seite 166

224 Pascal 4.0 User’s Guide10Compiling with LibrariesMost XView procedures you call are in the libraries pxview, xview, and X11.To compile an XView pr

Seite 167

The XView Toolkit 22510Instead of these routines, the Pascal interface to XView defines a separateroutine to get and set each attribute.• set—The routi

Seite 168

1Introduction1This chapter gives an overview of the features of Pascal, includingcompatibility, internationalization, and licensing. It contains the

Seite 169

226 Pascal 4.0 User’s Guide10Example calls are:The lists for Attr_avlist are created by functions that have the followingnames:attr_create_list_n()att

Seite 170

The XView Toolkit 22710Coding FragmentHere is an example that illustrates the style of programming with the XViewinterface in Pascal. This program:•

Seite 171

228 Pascal 4.0 User’s Guide10The Straightforward Part—You can use the following items of information asyou find them in the manual, with no change:• Th

Seite 172

The XView Toolkit 22910Sample Translation of an XView Function to PascalIn the section, “Summary of Procedures and Macros,” in the XViewProgramming Ma

Seite 173

230 Pascal 4.0 User’s Guide10Sample ProgramThe following program, xview.p, makes a window:To compile xview.p and link in the necessary libraries, use

Seite 174 - Arguments Passed by Value

The XView Toolkit 23110Menu Demo ProgramHere is a more complicated program, menu_demo.p, that makes a windowand a panel with a menu button. The choic

Seite 175

232 Pascal 4.0 User’s Guide10To compile menu_demo.p and link in the necessary libraries, use the followingcommand-line:hostname% pc menu_demo.p -Ipasc

Seite 176

233Math Libraries11This chapter describes how to use the libm and libsunmath functions inPascal programs. The math libraries are always accessible fr

Seite 177 - Simple Types

234 Pascal 4.0 User’s Guide11Contents of the Math LibrariesAltogether, there are three math libraries:• libm.a—A set of functions required by the vari

Seite 178 - Type shortreal

Math Libraries 23511Legend:mFunctions available in bundled libmm+Functions available in bundled libm and as single-precision version onlyin libsunmath

Seite 179 - Procedure Calls: Pascal–C++

2 Pascal 4.0 User’s Guide1Pascal CompilerThe name of the Pascal compiler is pc. If given an argument file name endingwith .p or .pas, pc compiles the

Seite 180

236 Pascal 4.0 User’s Guide11The following Pascal program is an example of how to use math functions.IEEE Support FunctionsThis section describes the

Seite 181

Math Libraries 23711ieee_functions()The functions described in ieee_functions(3M) provide capabilities eitherrequired by the IEEE standard or recommen

Seite 182

238 Pascal 4.0 User’s Guide11ieee_retrospective()The libm function ieee_retrospective() prints to stderr informationabout unrequited exceptions and no

Seite 183

Math Libraries 23911Arithmetic ExceptionsAn arithmetic exception arises when an attempted atomic arithmetic operationdoes not produce an acceptable re

Seite 184

240 Pascal 4.0 User’s Guide11• Division by zero—The divisor is zero, and the dividend is a finite non-zeronumber; or, more generally, an exact infinite

Seite 185 - Pascal. See this example:

Math Libraries 24111If your matherr() function returns a non-zero result, no exception message isprinted, and errno is not set.DOMAIN Argument domain

Seite 186 - Pascal File Pointers to C++

242 Pascal 4.0 User’s Guide11libsunmath Support for IEEE Modes and Exceptionsieee_handler() is used primarily to establish a signal handler for aparti

Seite 187 - The FORTRAN–Pascal Interface

Math Libraries 24311The syntax of this function is described in the ieee_flags(3M) man page.If an exception is raised at any time during program execu

Seite 188

244 Pascal 4.0 User’s Guide11

Seite 189 - , byte, or

245Pascal PreprocessorAThis appendix describes the preprocessors, cpp(1) and cppas.cppcpp(1) is the C language preprocessor. Pascal runs your source

Seite 190

Introduction 31Text EditorsThe operating system provides two main editors:• Text Editor—A window-based text editor that runs in the OpenWindowsenviron

Seite 191 - Multidimensional Arrays

246 Pascal 4.0 User’s GuideAA defined conditional variable is enabled (true) when it appears in either the%enable directive or in the –config option;

Seite 192

Pascal Preprocessor 247AThe rest of this appendix contains detailed descriptions and examples of eachdirective.The%config DirectiveThe %config directi

Seite 193 - See the following example:

248 Pascal 4.0 User’s GuideAExampleThe Pascal program,config.p, which defines theconditional variables one andtwoprogram config_example(output);{ This

Seite 194

Pascal Preprocessor 249AThe %debug DirectiveThe %debug directive instructs pc to compile this line of code when you usethe –cond compiler directive.Sy

Seite 195

250 Pascal 4.0 User’s GuideAExampleThe %else DirectiveThe %else directive provides an alternative action to the %if directive.Syntax%if expression %th

Seite 196

Pascal Preprocessor 251AExampleThe %elseif DirectiveThe %elseif directive provides an alternative action to the %if directive.Syntax%if expression %th

Seite 197

252 Pascal 4.0 User’s GuideACommentsIf the expression in %if expression %then is false, pc skips over the %thenpart and executes the %elseif part inst

Seite 198

Pascal Preprocessor 253ASyntax%ifdef expression %then . .%elseifdef expression %then . .%endifCommentsIf the expression in %ifdef expr

Seite 199

254 Pascal 4.0 User’s GuideAThe %enable DirectiveThe %enable directive sets a conditional variable to true.Syntax%enable var1 ..., varNCommentsA define

Seite 200

Pascal Preprocessor 255AExampleThe %endif DirectiveThe %endif directive indicates the end of a %if or %ifdef directive. See thesections on %if and %i

Seite 201

4 Pascal 4.0 User’s Guide1InternationalizationA product can support up to four levels of internationalization:• Level 1—Allows native-language charact

Seite 202

256 Pascal 4.0 User’s GuideASyntax%error 'string'Commentspc does not produce an object file.ExampleThe%exit DirectiveThe %exit directive inst

Seite 203 - Pascalintset Type

Pascal Preprocessor 257ACommentsIf the compiler encounters an %exit directive within an include file, it stopsprocessing the include file, but continues

Seite 204

258 Pascal 4.0 User’s GuideACommentsWhen pc encounters a %if directive, it evaluates expression. If expression istrue, pc executes the statements in

Seite 205

Pascal Preprocessor 259ACommentsexpression consists of a conditional variable and the optional booleanoperators and, or, and not. See the %else listi

Seite 206 - Typeshortreal

260 Pascal 4.0 User’s GuideAThe %list DirectiveThe %list directive enables a listing of the program.Syntax%list;The module unit,include_mod.pmodule in

Seite 207 - Pointers

Pascal Preprocessor 261ACommentsThe %list directive and the -l compiler option perform the same function.ExampleThe Pascal program, list.p program lis

Seite 208

262 Pascal 4.0 User’s GuideAThe %nolist DirectiveThe %nolist directive disables the program listing.Syntax%nolist;Comments%nolist is the default.Examp

Seite 209

Pascal Preprocessor 263AThe %slibrary Directivecppas treats %slibrary in the same manner as the %include directive. See“The %include Directive” on pa

Seite 210

264 Pascal 4.0 User’s GuideAExampleThe Pascal program,warning.pprogram warning_example(output);{ This program demonstrates the use of the %warning co

Seite 211

265Error MessagesBThe following is a list of the error messages produced by Pascal, arranged bymessage number.10010: Builtin <function> takes ex

Seite 212

Introduction 51If you reset your system locale to, for example, France, and rerun the program,the output is the same. Pascal does not replace the per

Seite 213 - Character Dummy Arguments

266 Pascal 4.0 User’s GuideB10120: Too many arguments to <function>10130: Actual argument cannot be conformant array10140: Actual argument is in

Seite 214

Error Messages 267B10290: Fourth argument to <function> must be of type <type>,not <type>10300: First argument to <function> c

Seite 215

268 Pascal 4.0 User’s GuideB10470: ord's argument must be of scalar type, not <type>10480: <function>'s argument must be of scal

Seite 216

Error Messages 269B10660: Second and successive arguments to <function> must beconstants10670: Argument to <function> must be a alfa, not

Seite 217

270 Pascal 4.0 User’s GuideB10840: Illegal argument with format radix specification;probably a comma missing11010: have incompatible conformant array

Seite 218

Error Messages 271B11170: For-statement variable <identifier> cannot be an elementof a record11180: . allowed only on records, not on <type>

Seite 219

272 Pascal 4.0 User’s GuideB12060: Width expressions allowed only in writeln/writecalls12070: Cannot write <type>s with two write widths12080: C

Seite 220

Error Messages 273B13070: constant argument expected13080: newline in string or char constant13090: empty character constant13100: too many characters

Seite 221

274 Pascal 4.0 User’s GuideB14140: PUBLIC ignored, procedure was declared INTERNAL orPRIVATE previously14150: PRIVATE ignored, procedure was declared

Seite 222

Error Messages 275B14300: Expected keyword begin after declarations, beforestatements14310: Improper initialization for variable <identifier>1432

Seite 223

iiiContentsPreface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix1. Introduction. . . . .

Seite 224

6 Pascal 4.0 User’s Guide1

Seite 225

276 Pascal 4.0 User’s GuideB15100: Cannot open #include file <filename>15110: line <number> does not exist in file <identifier>15120:

Seite 226 - Routines as Parameters

Error Messages 277B16160: Procedure/function nesting too deep16170: Can't call <identifier>, its not a pointer to aprocedure or function161

Seite 227

278 Pascal 4.0 User’s GuideB17100: Predecessor of <integer> is out of range17110: Value of <integer> is out of range17120: Range upper bou

Seite 228 - 204 Pascal 4.0 User’s Guide

Error Messages 279B18120: 8 or 9 in octal number18130: Number too large for this implementation18140: <operation> is undefined for reals18150: &

Seite 229 - Error Diagnostics

280 Pascal 4.0 User’s GuideB18420: Undefined <identifier>18430: Undefined identifier18440: Improper <identifier> identifier18450: Deleted &l

Seite 230 - Digits in Real Numbers

Error Messages 281B18630: Unreachable statement18640: Unrecoverable syntax error - QUIT18650: Too many syntax errors - QUIT18660: Input line too long

Seite 231

282 Pascal 4.0 User’s GuideB19030: Missing program statement19040: Input is used but not defined in the programstatement19050: Output is used but not

Seite 232

Error Messages 283B20140: Operands of <operator> must both be sets20150: Set types of operands of <operator> must be compatible20160: Inco

Seite 233

284 Pascal 4.0 User’s GuideB21070: Conformant array parameters in the samespecification must be the same type21080: actual parameter is not an array21

Seite 234 - Compiler Semantic Errors

Error Messages 285B21230: Program parameter <identifier> is repeated21240: Previous declaration for formal parameter '<identifier>&apos

Seite 235 - Thescalar Class

7Pascal Programs2This chapter cites two examples that illustrate how to compile and execute aprogram. It also explains how to use the traceback facil

Seite 236 - Expression Diagnostics

286 Pascal 4.0 User’s GuideB22020: Ran out of memory (case)22030: Ran out of memory (hash)22040: Ran out of memory (TRIM)22050: Ran out of memory (def

Seite 237

Error Messages 287B23070: Routine Options are not standard23080: External procedures and functions are not standard23090: Separately compiled routine

Seite 238 - Type Equivalence

288 Pascal 4.0 User’s GuideB23270: Storage Class non-standard23280: Initialization in declaration part is non-standard23290: UNIV_PTR types are non-st

Seite 239 - Unreachable Statements

Error Messages 289B24120: Case selectors cannot be <type>s24130: Duplicate otherwise clause in case statement24140: Case label type clashed with

Seite 240 - Uninitialized Variables

290 Pascal 4.0 User’s GuideB24300: Improper use of the DEFINE statement24310: End matched <keyword> on line <number>24320: Inserted keywor

Seite 241 - Runtime Errors

Error Messages 291B25150: Type clash: packed and unpacked set25160: Type clash: files not allowed in this context25170: Type clash: non-identical <

Seite 242 - 218 Pascal 4.0 User’s Guide

292 Pascal 4.0 User’s GuideB25320: Function type should be given only in forwarddeclaration25330: Different type declared previously for functionretur

Seite 243 - Error Diagnostics 219

Error Messages 293B25490: <class> types must be identical in comparisons -operator was <operator>25500: Index type clashed with set compon

Seite 244 - 220 Pascal 4.0 User’s Guide

294 Pascal 4.0 User’s GuideB25670: Index type for arrays cannot be real25680: Array index type is a <type>, not a range or scalaras required2569

Seite 245 - The XView Toolkit

Error Messages 295B26140: Extension to WITH statement not allowed27010: Integer overflow in constant expressionThe following are internal error messag

Seite 246 - Object-Oriented Programming

8 Pascal 4.0 User’s Guide2Compiling the ProgramNow compile the program with pc, the Pascal compiler, by typing at thesystem prompt:hostname% pc temp.p

Seite 247 - Pascal Interface

296 Pascal 4.0 User’s GuideB

Seite 248 - Header Files

297IndexA–a option to pc command, 24a.out, 2,8,9,17address parameters, 169alignment of types in FORTRAN, 165and operator, 38AnswerBook, xxiiarguments,

Seite 249 - Attribute Lists

298 Pascal 4.0 User’s Guidevar parameters, 94, 117C++ programming language, 137 to 162arguments, passing ofby reference, 139, 155by value, 150, 157arr

Seite 250

Index 299–config option, 245, 252, 256defined, 246undefined, 245%config directive, 247–config option to pc command, 27, 246,252conformant arraysparamete

Seite 251 - Conversion of C to Pascal

300 Pascal 4.0 User’s Guidein type equivalence, 214out of memory, 217runtime, 217 to 220exception-handling function in mathlibraries, 240executable fil

Seite 252 - 1. Defined in stddefs_p.h

Index 301identifier errors, 208identifiers, 33, 46, 76IEEE support functions in mathlibraries, 236%if directive, 247, 257%ifdef directive, 255, 257, 258

Seite 253

302 Pascal 4.0 User’s Guidematherr() exception-handlingfunction, 240Pascal header files, 233SPARC libraries, 238memory, out of, 217–misalign option to

Seite 254 - Sample Program

Index 303–dalign option, 28–dn option, 28–dryrun option, 28–dy option, 28–fast option, 28-flags option, 32–fnonstd option, 29-fns option, 29-fround=r

Seite 255 - Menu Demo Program

304 Pascal 4.0 User’s Guideprocedureand function type errors, 211extern option, 86, 88external,88linelimit,25type errors, 211write,46programbreakup of

Seite 256 - Now run the executable file:

Index 305#define,27assert,25stdin,10stdout,10string errors, 206symbolerrors, 208table for dbx,61syntax errors and recovery, 205 to 207T-tc option to p

Seite 257 - Math Libraries

Pascal Programs 92Running the ProgramTo run the program, enter a.out at the prompt. The output of temp.p is thendisplayed:Renaming the Executable Fil

Seite 258

306 Pascal 4.0 User’s Guidewriting a Pascal program, 7writing scalars, errors in, 212X–xarch=a option to pc command, 49–xcache=a option to pc command,

Seite 259

Index 307

Seite 260 - IEEE Support Functions

Copyright 1995 Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, Californie 94043-1100 U.S.A.Tous droits réservés. Ce produit ou document est

Seite 262 - SPARC Libraries

10 Pascal 4.0 User’s Guide2Now run the program by typing the name of the executable file. The outputfollows:An Interactive Pascal ProgramIn Pascal, th

Seite 263 - Arithmetic Exceptions

Pascal Programs 112Compiling the ProgramUse the pc command to compile the program and store it in the executable filecopy. Here is the command format:

Seite 264

12 Pascal 4.0 User’s Guide2Using the same program, but with the < operator to redirect input, you canprint the file on the terminal:Using a File Nam

Seite 265

Pascal Programs 132Assuming that the file data is still in the current directory, you can compileand run the program as follows:Where Did My Program Fa

Seite 266

14 Pascal 4.0 User’s Guide2Using a Sample Program with Segmentation ViolationA segmentation violation occurs when your program tries to reference memo

Seite 267

Pascal Programs 152In this example, ErrorInHere reported the error. The ErrorInHereprocedure was called by Call1.Call2, which was in turn called by t

Seite 268 - 244 Pascal 4.0 User’s Guide

iv Pascal 4.0 User’s GuideCompiling the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Running the Program . . . . . . . . . . .

Seite 269 - Pascal Preprocessor

16 Pascal 4.0 User’s Guide2Try compiling SegViol.p with –g:The program prints the ASCII values of character variables.If you compile some modules with

Seite 270 - Compiler Directives

17The Pascal Compiler3The name of the Pascal compiler is pc. If you give pc a file name as anargument, and the file name ends with .p or .pas, pc compi

Seite 271 - The%config Directive

18 Pascal 4.0 User’s Guide3To identify the version number given an executable or object file created by thePascal compiler, use the following command.C

Seite 272

The Pascal Compiler 193Figure 3-1 shows the sequence of events when you invoke pc.Figure 3-1 Organization of Pascal CompilationLanguage PreprocessorTh

Seite 273 - The %debug Directive

20 Pascal 4.0 User’s Guide3See the man page for cpp(1) for information on its directives and otherfeatures. Appendix A, “Pascal Preprocessor,” describ

Seite 274 - The %else Directive

The Pascal Compiler 213Option-Passing on the Command-LineTo pass an option on the command-line, use a dash (-) followed by the optionname. In some ca

Seite 275 - The %elseif Directive

22 Pascal 4.0 User’s Guide3You set options within comments, which can be delimited by either { and } or(* and *). The first character in the comment m

Seite 276 - The%elseifdef Directive

The Pascal Compiler 233If no values have been pushed onto the stack, the effect of * is undefined.Figure 3-2 illustrates how options are passed in prog

Seite 277 - Comments

24 Pascal 4.0 User’s Guide3–aThe –a option is the old style of basic block profiling for tcov. See-xprofile=tcov for information on the new style of p

Seite 278 - The %enable Directive

The Pascal Compiler 253The –b option on the command-line turns on block-buffering with a block sizeof 1,024. You cannot turn off buffering from the c

Seite 279 - The%error Directive

Contents v–c. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26-calign . . . . . . . . . . . . . . . .

Seite 280 - The%exit Directive

26 Pascal 4.0 User’s Guide3–cThe –c option instructs the compiler not to call the linker, ld(1). The Pascalcompiler, pc, leaves a .o or object file fo

Seite 281 - The%if Directive

The Pascal Compiler 273The –cond option instructs pc to compile the lines in your program that beginwith the %debug compiler directive. If you compil

Seite 282 - The%ifdef Directive

28 Pascal 4.0 User’s Guide3–dalignThe –dalign option instructs the compiler to generate double load and storeinstructions wherever possible for faster

Seite 283 - The%include Directive

The Pascal Compiler 293Do not use this option for programs that depend on IEEE standard exceptionhandling; you can get different numerical results, pr

Seite 284 - The %list Directive

30 Pascal 4.0 User’s Guide3The default is -fround=nearest.The meanings are the same as those for the ieee_flags subroutine.If you compile one routine

Seite 285

The Pascal Compiler 313–gThe –g option instructs pc to produce additional symbol table information fordbx and debugger. With -g, the incremental link

Seite 286 - The %nolist Directive

32 Pascal 4.0 User’s Guide3Every executable file has a list of needed shared library files. When theruntime linker links the library into an executable

Seite 287 - The%warning Directive

The Pascal Compiler 333–LThe –L option maps all keywords and identifiers to lowercase. In Pascal,uppercase and lowercase are not interchangeable in id

Seite 288

34 Pascal 4.0 User’s Guide3-libmieeeForces IEEE 754 style return values for math routines in exceptional cases. Insuch cases, no exception message is

Seite 289 - Error Messages

The Pascal Compiler 353–nativeThe –native option causes pc to generate code for the best floating-pointhardware available on the machine you are compil

Seite 290 - 266 Pascal 4.0 User’s Guide

vi Pascal 4.0 User’s Guide–L. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33–l. . . . . . . . . . .

Seite 291 - Error Messages 267

36 Pascal 4.0 User’s Guide3-notraceThe -notrace option disables runtime traceback. It is only effective whencompiling the main program.–O[level]The –

Seite 292 - 268 Pascal 4.0 User’s Guide

The Pascal Compiler 373–O3, -xO3Same as -O2, but optimizes the uses and definitions of external variables.Level -O3 does not trace the effects of point

Seite 293 - Error Messages 269

38 Pascal 4.0 User’s Guide3This command causes the optimizer to try to recover if it reaches 16 megabytesof data space.This limit cannot be greater th

Seite 294 - 270 Pascal 4.0 User’s Guide

The Pascal Compiler 393–p and –pgThe –p and –pg options instruct the compiler to produce code that counts thenumber of times each routine is called.

Seite 295 - Error Messages 271

40 Pascal 4.0 User’s Guide3–QoptionThe –Qoption passes an option to the program. The option value must beappropriate to that program and can begin wi

Seite 296 - 272 Pascal 4.0 User’s Guide

The Pascal Compiler 413-R(Solaris 1.x only) The –R option instructs pc to call the assembler, as(1). Thisoption merges the data segment of the resul

Seite 297 - Error Messages 273

42 Pascal 4.0 User’s Guide3The compiler issues warnings at the end of the procedure where the recordvariables are defined, that is, when some of the fie

Seite 298 - 274 Pascal 4.0 User’s Guide

The Pascal Compiler 433Examples:The Pascal main program, r.p(record and array of records)program p;procedure qq;type compl = record re, im: integer en

Seite 299 - Error Messages 275

44 Pascal 4.0 User’s Guide3The commands to compilerr.p and the -Rw warningsthat are issuedhostname% pc -Rw rr.pMon Feb 20 14:59:04 1995 pas/rr.p:In p

Seite 300 - 276 Pascal 4.0 User’s Guide

The Pascal Compiler 453The Pascal main program,with.p (with statement)program p;type C = record re, im: integer end; AC = array[1..2] of C; RC

Seite 301 - Error Messages 277

Contents vii-R path[:dir] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41-Rw. . . . . . . . . . . . . . . . . . . . . .

Seite 302 - 278 Pascal 4.0 User’s Guide

46 Pascal 4.0 User’s Guide3–SThe –S option compiles the program and outputs the assembly language in thefile, sourcefile.s. For example, the following

Seite 303 - Error Messages 279

The Pascal Compiler 473-tcThe -tc option instructs the compiler to generate pc3 stab information thatallows cross-module type checking.This option can

Seite 304 - 280 Pascal 4.0 User’s Guide

48 Pascal 4.0 User’s Guide3–timeThe –time option instructs the compiler to report execution performancestatistics for the various compilation passes.

Seite 305 - Error Messages 281

The Pascal Compiler 493–U nameThe –U option removes any initial definition of the cpp(1) symbol name. Seecpp(1) for more information. You cannot use

Seite 306 - 282 Pascal 4.0 User’s Guide

50 Pascal 4.0 User’s Guide3a must be one of: generic, v7, v8, v8a, v8plus, v8plusa.Although this option can be used alone, it is part of the expansion

Seite 307 - Error Messages 283

The Pascal Compiler 513v7, v8, and v8a are all binary compatible. v8plus and v8plusa are binarycompatible with each other and forward, but not backwar

Seite 308 - 284 Pascal 4.0 User’s Guide

52 Pascal 4.0 User’s Guide3v8 Limit the instruction set to V8 architecture.This option uses the best instruction set for good performance on the V8arc

Seite 309 - Error Messages 285

The Pascal Compiler 533-xcache=c(Solaris 2.x only) The -xcache=c option defines the cache properties for use bythe optimizer.c must be one of the follo

Seite 310 - 286 Pascal 4.0 User’s Guide

54 Pascal 4.0 User’s Guide3Example: -xcache=16/32/4:1024/32/1 specifies the following:-xchip=c(Solaris 2.x only) The -xchip=c option specifies the targe

Seite 311 - Error Messages 287

The Pascal Compiler 553-xcg89Same as -cg89.-xcg92Same as -cg92.–xF(Solaris 2.x only) The –xF option enables performance analysis of the executablefile

Seite 312 - 288 Pascal 4.0 User’s Guide

viii Pascal 4.0 User’s Guide-xlibmieee . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56-xlibmil. . . . . . . . . . . .

Seite 313 - Error Messages 289

56 Pascal 4.0 User’s Guide3-xildoff(Solaris 2.x only) Turns off the incremental linker and forces the use of ld. Thisoption is the default if you do

Seite 314 - 290 Pascal 4.0 User’s Guide

The Pascal Compiler 573-xlibmoptUses a math routine library optimized for performance. The results may beslightly different than those produced by th

Seite 315 - Error Messages 291

58 Pascal 4.0 User’s Guide3Generates the highest level of optimization. Uses optimization algorithms thattake more compilation time or that do not hav

Seite 316 - 292 Pascal 4.0 User’s Guide

The Pascal Compiler 593This option causes execution frequency data to be collected and saved duringexecution, then the data can be used in subsequent

Seite 317 - Error Messages 293

60 Pascal 4.0 User’s Guide3-xregs=r(Solaris 2.x only) The -xregs=r option specifies the usage of registers for thegenerated code.r is a comma-separated

Seite 318 - 294 Pascal 4.0 User’s Guide

The Pascal Compiler 613–xs(Solaris 2.x only) The -xs option disables Auto-Read for dbx in case youcannot keep the .o files around. This option passes

Seite 319 - Error Messages 295

62 Pascal 4.0 User’s Guide3-xspace(Solaris 2.x only) The -xspace option does no optimizations that increase thecode size.Example: Do not unroll loops.

Seite 320 - 296 Pascal 4.0 User’s Guide

The Pascal Compiler 633very important. This is especially true when running on the newer SPARCprocessors. However, for most programs and older SPARC p

Seite 321

64 Pascal 4.0 User’s Guide3sun4/670 v7 old 64/32/1sun4/690 v7 old 64/32/1sselc v7 old 64/32/1ssipc v7 old 64/16/1ssipx v7 old 64/32/1sslc v8a micro 2/

Seite 322

The Pascal Compiler 653ss10/51 v8 super 16/32/4:1024/32/1ss10/61 v8 super 16/32/4:1024/32/1ss10/71 v8 super2 16/32/4:1024/32/1ss10/402 v8 super 16/32/

Seite 323

Contents ixSharing Variables Between Units. . . . . . . . . . . . . . . . . . . . . . 71Libraries . . . . . . . . . . . . . . . . . . . . . . . . . .

Seite 324

66 Pascal 4.0 User’s Guide3–ZThe –Z option instructs pc to insert code that initializes all local variables tozero. Standard Pascal does not allow in

Seite 325

67Program Construction andManagement4This chapter is an introduction to the methods generally used to construct andmanage programs using Pascal. It d

Seite 326

68 Pascal 4.0 User’s Guide4The actual includefile looks like this:In this example, the include file contains the entire program. In reality, aninclude

Seite 327

Program Construction and Management 694The body of the procedure say_hello is not defined in this program unit,but the program unit does contain a decl

Seite 328

70 Pascal 4.0 User’s Guide4You can also separate the compilation and linking or loading steps, as follows:hostname% pc program_unit.p -chostname% pc m

Seite 329

Program Construction and Management 714In a real program, header.h would probably contain many declarations andwould be included in several modules.

Seite 330

72 Pascal 4.0 User’s Guide4Here is a program unit that declares a variable:Here is a module unit that declares a variable with the same name:program p

Seite 331 - Index 307

Program Construction and Management 734By default, both definitions of variable x are public. Thus, when you compileand link the program and module un

Seite 332

74 Pascal 4.0 User’s Guide4LibrariesYou can use a module unit as a library of useful functions. The simplest wayto do so is to create a source file co

Seite 333

75Separate Compilation5This chapter describes how to compile Pascal programs in separate units.Chapter 4, “Program Construction and Management,” gives

Kommentare zu diesen Handbüchern

Keine Kommentare