Pascal 4.0 User’s Guide
 Trademarks
 Contents
 Pascal Compiler
 Contents
 Pic, -Kpicand -PIC, -KPIC
 Contents Vii
 Program Construction and Management
Viii
 Separate Compilation
 C++-Pascal Interface
 Error Diagnostics
 XView Toolkit
Xii
 Contents Xiii
Math Libraries
 Xiv
 Figures
 Pascal 4.0 User’s Guide
 Tables
Fortran
 Xviii
 Installation
Preface
Operating Environment
 Audience
Organization
 Conventions Used in This Guide
AaBbCc123
 Shell Prompts in Command Examples
Related Documentation
Manual
 Readme Files
Other Related Documentation
Documents in Hard Copy and in AnswerBook
Hostname% imagetool floating-point.ps
 CD-ROM
 Introduction
Standards
 Features
Pascal Compiler
Compatibility
 Text Editors
Debuggers
XView Toolkit
Native Language Support
 Internationalization
 Licensing
Locale
 Pascal 4.0 User’s Guide
 Pascal Programs
Simple Pascal Program
 Compiling the Program
 Running the Program
Renaming the Executable File
Hostname% mv a.out temp
Hostname% pc -o temp temp.p
 An Interactive Pascal Program
 Redirecting I/O
Hostname% pc -o copy copy.p
Hello, are you listening?
Goodbye, I must go now
 Using a File Name as a File Variable
 Where Did My Program Fail?
Using Pascal Traceback
Hostname% pc -o copy2 copy2.p
 Using a Sample Program with Segmentation Violation
Compiling and Running the Program
 Using the -gOption
Hostname% more a.out.trace
 Try compiling SegViol.p with -g
 Pascal Compiler
Pc Version Number
 Compile and Link Sequence
Hostname% mcs -p a.out grep Pascal
 Language Preprocessor
Source
Compiler Preprocessor cpp or cppas
Optimizer
 File Name Extensions Accepted By pc
Suffix Description
 Option-Passing on the Command-Line
Option-Passing in the Program Text
Hostname% pc -l rmc.p
Hostname% pc -o rmc rmc.p
 Option Description
 Options
Hostname% pc options.p
 Bbinding
 Bsdmalloc
 Calign
Cg89
Cg92
Cond
 Config
Dname=def
 Dalign
Dryrun
Fast
 Fnonstd
Fns
Fround=r
 Ftrap=t
 Hname
 Help or -flags
Ipathname
Iname
Keeptmp
 Ldirectory
Hostname% pc -l random.p
 Libmieee
Libmil
Llib
Misalign
 Native
Nocx
Nolib
Nolibmil
 Notrace
Olevel
 Hostname% limit datasize 16M
 Ofilename
Hostname% /usr/sbin/swap -s
Hostname% /usr/sbin/prtconf grep Memory
Hostname% pc -o myprog myprog.p
 Using the -pOption
Using the -pgOption
-pg
Pic,-Kpic and -PIC,-KPIC
 Qoption
Qpathpathname
Qproduce
 Rpathdir
 Pascal 4.0 User’s Guide
 Examples
 Hostname% pc -Rw rr.p
Hostname% pc -Rw recvar.p
 Commands to compile and execute with.p
Pascal main program, with.p with statement
Hostname% pc -Rw with.p
 Slevel
Sbfast
Hostname% pc -S rmc.p
 Temp=dir
Hostname% pc -temp=. hello.p
 Time
Hostname% pc -time hello.p
 Uname
Xarch=a
 Pascal 4.0 User’s Guide
 Value Meaning
 Limit the instruction set to V8 architecture
 Xcache=c
S1/l1/a1 S1/l1/a1s2/l2/a2 S1/l1/a1s2/l2/a2s3/l3/a3
 Xchip=c
Example -xcache=16/32/41024/32/1specifies the following
 Xcg89
Xcg92
 Xildoff
Xildon
Xlibmieee
Xlibmil
 Xlibmopt
Xlicinfo
XMerge
Xnolib
 Xpg
Xprofile=p
 -xprofileValues
 Xregs=r
Example -xregs=appl,no%float
 Xsafe=mem
Xsb
Xsbfast
 Xspace
Xtarget=t
 XtargetExpansions
 Pascal 4.0 User’s Guide
 Pascal Compiler
 Ztext
 Program Construction Management
Units
 Using Program Units and Module Units
 Compiling with Units
Hostname% pc programunit.p moduleunit.p
Program Construction and Management
 Using Units and Header Files
 Sharing Variables Between Units
 Here is a program unit that declares a variable
 Program Construction and Management
 Libraries
 Separate Compilation
Working with Units
 Using Program Units
Using Module Units
Sharing Variables and Routines Across Multiple Units
 Compiling without the -xlOption
Sharing Public Variables
Program unit
Separate Compilation
 Using extern Option to Share Routines
Using include Files to Share Variables and Routines
 Commands to compile and execute incprog.p and incmod.p
Program unit, incprog.p, which includes the file
Module unit, incmod.p, which also includes the file
Hostname% pc incprog.p incmod.p
 Using the -xlOption
Using public var Declarations
 Commands to compile and execute pubvarprog.p and pubvarmod.p
 Using the define Variable Attribute
 Using the define Declaration
Commands to compile and execute defvarprog.p and defvarmod.p
 Using include Files
Module unit
 Program unit, incprog2.p Module unit, incmod2.p
 Using extern
Commands to compile and execute incprog2.p and incmod2.p
Program unit, extprog.p
 Commands to compile and execute extprog.p and extmod.p
Sharing Declarations in Multiple Units
Module unit, extmod.p
 Pascal 4.0 User’s Guide
 C-Pascal Interface
Compilation of Mixed-Language Programs
 Compatibility of Types for C and Pascal
Hostname% cc -c myc.c Hostname% pc -calign myc.o mypascal.p
 Precautions with Compatible Types
Character Strings
C-Pascal Interface
 Incompatibilities
Array Indexes
Aggregate Types
Enumerated Types
 Procedure Calls C-Pascal
General Parameter Passing in C and Pascal
Pascal Set Types
 Commands to compile and execute Samp.p
Variable Parameters
 Pascal procedure, SimVar.p
Simple Types without -xl
 Commands to compile and execute SimVar.p and SimVarMain.c
Pascal procedure
Simple Types with -xl
Strings of Characters
 Commands to compile and execute StrVar.p and StrVarMain.c
Fixed Arrays
C main program
 Pascal procedure, FixVec.p
Commands to compile and execute FixVec.p and FixVecMain.c
 Day =
 Univ Arrays
100
 Conformant Arrays
C-Pascal Interface 101
 Example 1 Single-Dimension Array
102
 Example 2 Multi-Dimension Array
C-Pascal Interface 103
 Example 3 Array of Characters
104
 Records and Structures
C-Pascal Interface 105
 Commands to compile and execute StruChr.p and StruChrMain.c
106
 Pascal routine
C-Pascal Interface 107
 Variant Records
108
 Commands to compile and execute VarRec.p and VarRecMain.c
C-Pascal Interface 109
 Pascal Set Type
110
 Pascal intset Type
C-Pascal Interface 111
 Value Parameters
112
 Commands to compile and execute SimVal.p and SimValMain.c
C-Pascal Interface 113
 Arrays
114
 Function Return Values
Simple Types
Pascal function
C-Pascal Interface 115
 Commands to compile and execute RetReal.p and RetRealMain.c
Pascal procedure, IO.p C main program, IOMain.c
Input and Output
116
 Procedure Calls Pascal-C
Hostname% cc IO.o IOMain.c -lpc
C function, SimRef.c
C-Pascal Interface 117
 118
 C function, StrVar.c
Pascal main program, StrVarMain.p
C-Pascal Interface 119
 Commands to compile and execute StrVar.c
Incorrect use of string in static variable storage
120
 Commands to compile and execute FixVec.c
C function, FixVec.c
Pascal main program
C-Pascal Interface 121
 C function, UniVec.c
122
 C function, IntCA.c
C-Pascal Interface 123
 Commands to compile and execute IntCA.c and IntCAMain.p
C function, StruChr.c
124
 Commands to compile and execute StruChr.c and StruChrMain.p
StruChr.c
Calign StruChr.o StruChrMain.p
Out
 C function, VarRec.c
126
 Non-Pascal Procedures
Commands to compile and execute VarRec.c
C-Pascal Interface 127
 128
 C function, SimVal.c
C-Pascal Interface 129
 Commands to compile and execute SimVal.c
130
 Parameters That Are Pointers to Procedures
Commands to compile and execute RetReal.c and RetRealMain.p
C function, RetReal.c
C function, ProcPar.c
 Procedures and Functions as Parameters
132
 Pascal procedure, GloVar.p
Global Variables in C and Pascal
C-Pascal Interface 133
 C procedure, UseFilePtr.c
File-Passing Between Pascal and C
134
 C-Pascal Interface 135
 136
 C++-Pascal Interface
Sample Interface
 Procedure Calls C++-Pascal
Pascal procedure, Samp, in the file, Samp.p
Compatibility of Types for C++ and Pascal
++ Name Encoding
 Arguments Passed by Reference
C++ main program, SampMain.cc
Hostname% pc -c Samp.p
C++-Pascal Interface 139
 Pascal procedure, SampRef, in the file, Samp.p
Simple Types without the -xlOption
140
 Commands to compile and execute SamRef.p and SamRefMain.cc
Simple Types with the -xlOption
C++ main program
Hostname% pc -c SamRef.p
 142
 Commands to compile and execute StrRef.p and StrRefMain.cc
Hostname% pc -c StrRef.p
C++-Pascal Interface 143
 Hostname% pc -c FixVec.p
144
 C++-Pascal Interface 145
 -calignoption
Hostname% pc -c DaysOfWeek.p
146
 Commands to compile and execute StruChr.p
Hostname% pc -c StruChr.p
C++-Pascal Interface 147
 148
 C++-Pascal Interface 149
 Arguments Passed by Value
Hostname% pc -c DayWeather.p
Hostname% pc -calign -c DayWeather.p
150
 C++-Pascal Interface 151
 Commands to compile and execute SimVal.p
152
 Commands to compile and execute RetReal.p
Hostname% pc -c RetReal.p
C++-Pascal Interface 153
 Input and Output
Hostname% pc -c RetShortReal.p
Pascal function, IO.p
154
 Procedure Calls Pascal-C++
C++ main program, IOMain.cc
Hostname% CC IO.o IOMain.cc -lpc hostname% a.out
C++-Pascal Interface 155
 Simple Types Passed by Reference
C++ function, SimRef.cc
156
 C++-Pascal Interface 157
 C++ function, SimVal.cc
158
 Commands to compile and execute SimVal.cc
C++-Pascal Interface 159
 C++ function, RetReal.cc
160
 Pascal procedure, GloVar.p C++ main program, GloVarMain.cc
Commands to compile and execute GloVar.p and GloVarMain.cc
Global Variables in C++ and Pascal
C++-Pascal Interface 161
 C++ procedure
Pascal File Pointers to C++
162
 FORTRAN-Pascal Interface
Compiler Mixed-Language Programs
 Compatibility of Types for Fortran and Pascal
164
 Real Integer Integer*2
FORTRAN-Pascal Interface 165
 166
 Multidimensional Arrays
General Parameter-Passing in Fortran and Pascal
FORTRAN-Pascal Interface 167
 Procedure Calls FORTRAN-Pascal
168
 Commands to compile and execute SimVar.p
Fortran main program
FORTRAN-Pascal Interface 169
 Pascal procedure, StrVar.p
Fortran main program, StrVarmain.f
170
 Commands to compile and execute StrVar.p and StrVarmain.f
Fortran main program, FixVecmain.f
FORTRAN-Pascal Interface 171
 Commands to compile and execute FixVec.p
172
 Commands to compile and execute UniVec.p and UniVecmain.f
FORTRAN-Pascal Interface 173
 Commands to compile and execute IntCA.p
174
 Commands to compile and execute ChrCA.p
Fortran main program, ChrCAmain.f
FORTRAN-Pascal Interface 175
 176
 FORTRAN-Pascal Interface 177
 178
 FORTRAN-Pascal Interface 179
 180
 FORTRAN-Pascal Interface 181
 Commands to compile and execute SimVal.p and SimValmain.f
182
 Pascal procedure, ChrCAx.p
Commands to compile and execute ChrCAx.p
Pointers
FORTRAN-Pascal Interface 183
 Commands to compile and execute PastPtr.p
184
 Procedure Calls Pascal-FORTRAN
Fortran main program, RetRealmain.f
FORTRAN-Pascal Interface 185
 Fortran subroutine
186
 FORTRAN-Pascal Interface 187
 Fortran subroutine, StrVar.f
188
 Commands to compile and execute StrVar.f and StrVarmain.p
Character Dummy Arguments
Hostname% f77 -c StrVar.f
Hostname% pc StrVar.o StrVarmain.p -lpfc -lF77
 Following example illustrates this method
190
 Commands to compile and execute FixVec.f
FORTRAN-Pascal Interface 191
 Fortran subroutine, UniVec.f
Pascal main program, UniVecmain.p
192
 Commands to compile and execute UniVec.f and UniVecmain.p
Hostname% f77 -c UniVec.f
FORTRAN-Pascal Interface 193
 Fortran subroutine, StruChr.f
194
 Commands to compile and execute StruChr.f and StruChrmain.p
Hostname% f77 -c StruChr.f
Hostname% pc StruChr.o StruChrmain.p -lpfc -lF77
FORTRAN-Pascal Interface 195
 196
 FORTRAN-Pascal Interface 197
 198
 FORTRAN-Pascal Interface 199
 200
 Commands to compile and execute PassPtr.f and PassPtrmain.p
Hostname% f77 -c PassPtr.f
Hostname% pc PassPtr.o PassPtrmain.p -lpfc -lF77
Fortran function, RetReal.f
 Commands to compile and execute RetReal.f and RetRealmain.p
Routines as Parameters
202
 FORTRAN-Pascal Interface 203
 204
 Error Diagnostics
Compiler Syntax Errors
Illegal Characters
 String Errors
Digits in Real Numbers
206
 Replacements, Insertions, and Deletions
Error Diagnostics 207
Hostname% pc synerr.p
 Expected Symbols and Malformed Constructs
Undefined or Improper Identifiers
208
 Error Diagnostics 209
Expected and Unexpected End-of-file
Hostname% pc synerr2.p
Pascal program, mism.p
 Compiler Semantic Errors
Format of the Error Diagnostics
Incompatible Types
210
 Procedure and Function Type Errors
Error Diagnostics 211
Scalar Class
 Scalar Error Messages
Expression Diagnostics
212
 This program generates the following error messages
Error Diagnostics 213
 Type Equivalence
214
 Error Diagnostics 215
Unreachable Statements
Pascal program, unreached.p
 Goto Statement
Uninitialized Variables
Unused Variables, Constants, Types, Labels, and Routines
Hostname% pc unreached.p
 Compiler Panics, I/O Errors
Runtime Errors
Error Diagnostics 217
 218
 Error Diagnostics 219
 220
 XView Toolkit
Overview
 Tools
Objects
Object-Oriented Programming
222
 Pascal Interface
Drawable Object Window Icon
XView Toolkit 223
 Attribute Procedures
Compiling with Libraries
Header Files
Names
 Attribute Lists
XView Toolkit 225
 Handles
Data Types
Here, mymenu is an object of type XVobject
226
 Conversion of C to Pascal
Coding Fragment
An Example
XView Toolkit 227
 Pascal
228
 Sample Translation of an XView Function to Pascal
XView Toolkit 229
 Sample Program
230
 Menu Demo Program
XView Toolkit 231
 Panelbutton
232
 Math Libraries
 Contents of the Math Libraries
 Libm Functions
Math Libraries 235
 Ieee Support Functions
236
 Ieeefunctions
Ieeevalues
Math Libraries 237
 Sparc Libraries
Ieeeretrospective
238
 Arithmetic Exceptions
Math Libraries 239
 Math Library Exception-Handling Function matherr
240
 Math Libraries 241
 Libsunmath Support for Ieee Modes and Exceptions
242
 Math Libraries 243
 244
 Pascal Preprocessor
Conditional Variables
 Compiler Directives
246
 %config Directive
Pascal Preprocessor 247
 Hostname% pc -xl config.p hostname% a.out
248
 Output when you define two
Output when you define foo
%debug Directive
Pascal Preprocessor 249
 %else Directive
Hostname% pc -xl -cond debug.p hostname% a.out
250
 Hostname% pc -xl -config red ifthenelse.p hostname% a.out
%elseif Directive
Pascal program, ifthenelse.p
Pascal Preprocessor 251
 Hostname% pc -xl -config blue elseif.p hostname% a.out
%elseifdef Directive
Pascal program
252
 Pascal Preprocessor 253
 %enable Directive
Hostname% pc -xl -config bird2 ifdef.p hostname% a.out
254
 %error Directive
Hostname% pc -xl enable.p hostname% a.out
%endif Directive
Pascal Preprocessor 255
 Error.p
%exit Directive
256
 %if Directive
Hostname% pc -xl exitdirective.p hostname% a.out
Pascal Preprocessor 257
 %ifdef Directive
258
 %include Directive
Pascal Preprocessor 259
 %list Directive
Module unit, includemod.p
260
 Pascal program, list.p
Pascal Preprocessor 261
 %nolist Directive
List.p
262
 %slibrary Directive
%var Directive
%warning Directive
Pascal Preprocessor 263
 Output when you compile warning.p without the -configoption
Pc -xl warning.p
264
 Error Messages
 266
 Error Messages 267
Fourth argument to function must be of type type, not type
 268
 Error Messages 269
 Function requires a to be an unpacked array, not type
270
 Error Messages 271
 272
 Error Messages 273
 274
 Error Messages 275
Identifier
 Unknown option for procedure pointer ignored option
276
 Error Messages 277
 278
 Error Messages 279
 280
 Error Messages 281
 Cannot mix sets with integers and reals as operands of type
282
 Error Messages 283
 284
 Error Messages 285
 286
 Error Messages 287
 288
 Error Messages 289
Multiply defined label in case, lines number and number
 290
 Error Messages 291
 292
 Error Messages 293
 OUT
294
 Error Messages 295
 296
 Index
297
 298
 Index 299
 300
 Index 301
 302
 Index 303
 304
 Index 305
 306
 Index 307
 Marques