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
 Preface
Installation
Operating Environment
 Audience
Organization
 Conventions Used in This Guide
AaBbCc123
 Related Documentation
Shell Prompts in Command Examples
Manual
 Documents in Hard Copy and in AnswerBook
Readme Files
Other Related Documentation
Hostname% imagetool floating-point.ps
 CD-ROM
 Introduction
Standards
 Pascal Compiler
Features
Compatibility
 XView Toolkit
Text Editors
Debuggers
Native Language Support
 Internationalization
 Licensing
Locale
 Pascal 4.0 User’s Guide
 Pascal Programs
Simple Pascal Program
 Compiling the Program
 Hostname% mv a.out temp
Running the Program
Renaming the Executable File
Hostname% pc -o temp temp.p
 An Interactive Pascal Program
 Hello, are you listening?
Redirecting I/O
Hostname% pc -o copy copy.p
Goodbye, I must go now
 Using a File Name as a File Variable
 Using Pascal Traceback
Where Did My Program Fail?
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
 Compiler Preprocessor cpp or cppas
Language Preprocessor
Source
Optimizer
 File Name Extensions Accepted By pc
Suffix Description
 Hostname% pc -l rmc.p
Option-Passing on the Command-Line
Option-Passing in the Program Text
Hostname% pc -o rmc rmc.p
 Option Description
 Options
Hostname% pc options.p
 Bbinding
 Bsdmalloc
 Cg92
Calign
Cg89
Cond
 Config
Dname=def
 Dryrun
Dalign
Fast
 Fns
Fnonstd
Fround=r
 Ftrap=t
 Hname
 Iname
Help or -flags
Ipathname
Keeptmp
 Ldirectory
Hostname% pc -l random.p
 Llib
Libmieee
Libmil
Misalign
 Nolib
Native
Nocx
Nolibmil
 Notrace
Olevel
 Hostname% limit datasize 16M
 Hostname% /usr/sbin/prtconf grep Memory
Ofilename
Hostname% /usr/sbin/swap -s
Hostname% pc -o myprog myprog.p
 -pg
Using the -pOption
Using the -pgOption
Pic,-Kpic and -PIC,-KPIC
 Qpathpathname
Qoption
Qproduce
 Rpathdir
 Pascal 4.0 User’s Guide
 Examples
 Hostname% pc -Rw rr.p
Hostname% pc -Rw recvar.p
 Pascal main program, with.p with statement
Commands to compile and execute with.p
Hostname% pc -Rw with.p
 Sbfast
Slevel
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
 Xlibmieee
Xildoff
Xildon
Xlibmil
 XMerge
Xlibmopt
Xlicinfo
Xnolib
 Xpg
Xprofile=p
 -xprofileValues
 Xregs=r
Example -xregs=appl,no%float
 Xsb
Xsafe=mem
Xsbfast
 Xspace
Xtarget=t
 XtargetExpansions
 Pascal 4.0 User’s Guide
 Pascal Compiler
 Ztext
 Program Construction Management
Units
 Using Program Units and Module Units
 Hostname% pc programunit.p moduleunit.p
Compiling with Units
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 Module Units
Using Program Units
Sharing Variables and Routines Across Multiple Units
 Program unit
Compiling without the -xlOption
Sharing Public Variables
Separate Compilation
 Using extern Option to Share Routines
Using include Files to Share Variables and Routines
 Module unit, incmod.p, which also includes the file
Commands to compile and execute incprog.p and incmod.p
Program unit, incprog.p, which 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
 Commands to compile and execute incprog2.p and incmod2.p
Using extern
Program unit, extprog.p
 Sharing Declarations in Multiple Units
Commands to compile and execute extprog.p and extmod.p
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
 Character Strings
Precautions with Compatible Types
C-Pascal Interface
 Aggregate Types
Incompatibilities
Array Indexes
Enumerated Types
 General Parameter Passing in C and Pascal
Procedure Calls C-Pascal
Pascal Set Types
 Commands to compile and execute Samp.p
Variable Parameters
 Pascal procedure, SimVar.p
Simple Types without -xl
 Simple Types with -xl
Commands to compile and execute SimVar.p and SimVarMain.c
Pascal procedure
Strings of Characters
 Fixed Arrays
Commands to compile and execute StrVar.p and StrVarMain.c
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
 Pascal function
Function Return Values
Simple Types
C-Pascal Interface 115
 Input and Output
Commands to compile and execute RetReal.p and RetRealMain.c
Pascal procedure, IO.p C main program, IOMain.c
116
 C function, SimRef.c
Procedure Calls Pascal-C
Hostname% cc IO.o IOMain.c -lpc
C-Pascal Interface 117
 118
 Pascal main program, StrVarMain.p
C function, StrVar.c
C-Pascal Interface 119
 Incorrect use of string in static variable storage
Commands to compile and execute StrVar.c
120
 Pascal main program
Commands to compile and execute FixVec.c
C function, FixVec.c
C-Pascal Interface 121
 C function, UniVec.c
122
 C function, IntCA.c
C-Pascal Interface 123
 C function, StruChr.c
Commands to compile and execute IntCA.c and IntCAMain.p
124
 Calign StruChr.o StruChrMain.p
Commands to compile and execute StruChr.c and StruChrMain.p
StruChr.c
Out
 C function, VarRec.c
126
 Commands to compile and execute VarRec.c
Non-Pascal Procedures
C-Pascal Interface 127
 128
 C function, SimVal.c
C-Pascal Interface 129
 Commands to compile and execute SimVal.c
130
 C function, RetReal.c
Parameters That Are Pointers to Procedures
Commands to compile and execute RetReal.c and RetRealMain.p
C function, ProcPar.c
 Procedures and Functions as Parameters
132
 Global Variables in C and Pascal
Pascal procedure, GloVar.p
C-Pascal Interface 133
 File-Passing Between Pascal and C
C procedure, UseFilePtr.c
134
 C-Pascal Interface 135
 136
 C++-Pascal Interface
Sample Interface
 Compatibility of Types for C++ and Pascal
Procedure Calls C++-Pascal
Pascal procedure, Samp, in the file, Samp.p
++ Name Encoding
 Hostname% pc -c Samp.p
Arguments Passed by Reference
C++ main program, SampMain.cc
C++-Pascal Interface 139
 Simple Types without the -xlOption
Pascal procedure, SampRef, in the file, Samp.p
140
 C++ main program
Commands to compile and execute SamRef.p and SamRefMain.cc
Simple Types with the -xlOption
Hostname% pc -c SamRef.p
 142
 Hostname% pc -c StrRef.p
Commands to compile and execute StrRef.p and StrRefMain.cc
C++-Pascal Interface 143
 Hostname% pc -c FixVec.p
144
 C++-Pascal Interface 145
 Hostname% pc -c DaysOfWeek.p
-calignoption
146
 Hostname% pc -c StruChr.p
Commands to compile and execute StruChr.p
C++-Pascal Interface 147
 148
 C++-Pascal Interface 149
 Hostname% pc -calign -c DayWeather.p
Arguments Passed by Value
Hostname% pc -c DayWeather.p
150
 C++-Pascal Interface 151
 Commands to compile and execute SimVal.p
152
 Hostname% pc -c RetReal.p
Commands to compile and execute RetReal.p
C++-Pascal Interface 153
 Pascal function, IO.p
Input and Output
Hostname% pc -c RetShortReal.p
154
 Hostname% CC IO.o IOMain.cc -lpc hostname% a.out
Procedure Calls Pascal-C++
C++ main program, IOMain.cc
C++-Pascal Interface 155
 C++ function, SimRef.cc
Simple Types Passed by Reference
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
 Global Variables in C++ and Pascal
Pascal procedure, GloVar.p C++ main program, GloVarMain.cc
Commands to compile and execute GloVar.p and GloVarMain.cc
C++-Pascal Interface 161
 Pascal File Pointers to C++
C++ procedure
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
 General Parameter-Passing in Fortran and Pascal
Multidimensional Arrays
FORTRAN-Pascal Interface 167
 Procedure Calls FORTRAN-Pascal
168
 Fortran main program
Commands to compile and execute SimVar.p
FORTRAN-Pascal Interface 169
 Fortran main program, StrVarmain.f
Pascal procedure, StrVar.p
170
 Fortran main program, FixVecmain.f
Commands to compile and execute StrVar.p and StrVarmain.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
 Fortran main program, ChrCAmain.f
Commands to compile and execute ChrCA.p
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
 Pointers
Pascal procedure, ChrCAx.p
Commands to compile and execute ChrCAx.p
FORTRAN-Pascal Interface 183
 Commands to compile and execute PastPtr.p
184
 Fortran main program, RetRealmain.f
Procedure Calls Pascal-FORTRAN
FORTRAN-Pascal Interface 185
 Fortran subroutine
186
 FORTRAN-Pascal Interface 187
 Fortran subroutine, StrVar.f
188
 Hostname% f77 -c StrVar.f
Commands to compile and execute StrVar.f and StrVarmain.p
Character Dummy Arguments
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
 Pascal main program, UniVecmain.p
Fortran subroutine, UniVec.f
192
 Hostname% f77 -c UniVec.f
Commands to compile and execute UniVec.f and UniVecmain.p
FORTRAN-Pascal Interface 193
 Fortran subroutine, StruChr.f
194
 Hostname% pc StruChr.o StruChrmain.p -lpfc -lF77
Commands to compile and execute StruChr.f and StruChrmain.p
Hostname% f77 -c StruChr.f
FORTRAN-Pascal Interface 195
 196
 FORTRAN-Pascal Interface 197
 198
 FORTRAN-Pascal Interface 199
 200
 Hostname% pc PassPtr.o PassPtrmain.p -lpfc -lF77
Commands to compile and execute PassPtr.f and PassPtrmain.p
Hostname% f77 -c PassPtr.f
Fortran function, RetReal.f
 Routines as Parameters
Commands to compile and execute RetReal.f and RetRealmain.p
202
 FORTRAN-Pascal Interface 203
 204
 Compiler Syntax Errors
Error Diagnostics
Illegal Characters
 Digits in Real Numbers
String Errors
206
 Error Diagnostics 207
Replacements, Insertions, and Deletions
Hostname% pc synerr.p
 Undefined or Improper Identifiers
Expected Symbols and Malformed Constructs
208
 Hostname% pc synerr2.p
Error Diagnostics 209
Expected and Unexpected End-of-file
Pascal program, mism.p
 Incompatible Types
Compiler Semantic Errors
Format of the Error Diagnostics
210
 Error Diagnostics 211
Procedure and Function Type Errors
Scalar Class
 Expression Diagnostics
Scalar Error Messages
212
 This program generates the following error messages
Error Diagnostics 213
 Type Equivalence
214
 Unreachable Statements
Error Diagnostics 215
Pascal program, unreached.p
 Unused Variables, Constants, Types, Labels, and Routines
Goto Statement
Uninitialized Variables
Hostname% pc unreached.p
 Runtime Errors
Compiler Panics, I/O Errors
Error Diagnostics 217
 218
 Error Diagnostics 219
 220
 XView Toolkit
Overview
 Object-Oriented Programming
Tools
Objects
222
 Drawable Object Window Icon
Pascal Interface
XView Toolkit 223
 Header Files
Attribute Procedures
Compiling with Libraries
Names
 Attribute Lists
XView Toolkit 225
 Here, mymenu is an object of type XVobject
Handles
Data Types
226
 An Example
Conversion of C to Pascal
Coding Fragment
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
 Ieeevalues
Ieeefunctions
Math Libraries 237
 Ieeeretrospective
Sparc Libraries
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
 %debug Directive
Output when you define two
Output when you define foo
Pascal Preprocessor 249
 Hostname% pc -xl -cond debug.p hostname% a.out
%else Directive
250
 Pascal program, ifthenelse.p
Hostname% pc -xl -config red ifthenelse.p hostname% a.out
%elseif Directive
Pascal Preprocessor 251
 Pascal program
Hostname% pc -xl -config blue elseif.p hostname% a.out
%elseifdef Directive
252
 Pascal Preprocessor 253
 Hostname% pc -xl -config bird2 ifdef.p hostname% a.out
%enable Directive
254
 %endif Directive
%error Directive
Hostname% pc -xl enable.p hostname% a.out
Pascal Preprocessor 255
 %exit Directive
Error.p
256
 Hostname% pc -xl exitdirective.p hostname% a.out
%if Directive
Pascal Preprocessor 257
 %ifdef Directive
258
 %include Directive
Pascal Preprocessor 259
 Module unit, includemod.p
%list Directive
260
 Pascal program, list.p
Pascal Preprocessor 261
 List.p
%nolist Directive
262
 %warning Directive
%slibrary Directive
%var Directive
Pascal Preprocessor 263
 Pc -xl warning.p
Output when you compile warning.p without the -configoption
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