Page 3 - Contents; xix
iii Contents Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
Page 4 - pc
iv Pascal 4.0 User’s Guide Compiling the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Running the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Renaming the Executable File . . . . . . . . . . . . . . . . . . . . . . . . 9 An Interactive Pascal Progra...
Page 5 - –config
Contents v –c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 -calign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 –cg89 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
Page 6 - level
vi Pascal 4.0 User’s Guide –L . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 –l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 -L directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
Page 7 - path
Contents vii -R path [: dir ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 -Rw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 –S . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
Page 8 - –xlicinfo
viii Pascal 4.0 User’s Guide -xlibmieee . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 -xlibmil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 -xlibmopt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
Page 9 - Compiling without the
Contents ix Sharing Variables Between Units . . . . . . . . . . . . . . . . . . . . . . 71 Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 5. Separate Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Working wit...
Page 12 - The
xii Pascal 4.0 User’s Guide The scalar Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 Procedure and Function Type Errors. . . . . . . . . . . . . . . . . . . 211 Scalar Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Expression Diagnost...
Page 13 - libm
Contents xiii An Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Sample Translation of an XView Function to Pascal . . . . . . 229 Sample Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 Menu Demo Program . . . . . . ...
Page 15 - Figures
xv Figures Figure 3-1 Organization of Pascal Compilation . . . . . . . . . . . . . . . . . . . . . . 19 Figure 3-2 Options in Program Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Figure 10-1 A Sample Class Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
Page 17 - Tables; –xl
xvii Tables Table 3-1 File Name Suffixes Recognized by Pascal . . . . . . . . . . . . . . . . . 20 Table 3-2 Options That Can Be Passed in Program Text . . . . . . . . . . . . . 21 Table 3-3 The -xarch Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Table 3-4 The -x...
Page 19 - Preface; Note –; unless otherwise indicated.; Operating Environment; For information on the operating environment, see the; Installation
xix Preface This manual describes the Pascal 4.0 compiler from SunSoft™. The purpose ofthis manual is to help you begin writing and compiling Pascal programs on aSPARCstation™. In a previous major release, this Pascal compiler also ran on Solaris 1.x. Somefeatures remain in the documentation as bein...
Page 20 - Audience; Chapter 4, “Program Construction and Management,”
xx Pascal 4.0 User’s Guide Audience This guide was prepared for software engineers who write Pascal programs ona SPARCstation. It assumes you are familiar with ISO standard Pascal and theSolaris™ operating system. Organization This guide contains the following chapters: • Chapter 1, “Introduction,” ...
Page 21 - lists all the error messages the compiler; Conventions Used in This Guide
Preface xxi • Appendix B, “Error Messages,” lists all the error messages the compiler produces. This guide concludes with an index. Conventions Used in This Guide This guide contains syntax diagrams of the Pascal language in extendedBackus-Naur Formalism (BNF) notation. Here are the meta symbols: Th...
Page 22 - Shell Prompts in Command Examples; Manual Page
xxii Pascal 4.0 User’s Guide Shell Prompts in Command Examples The following table shows the default system prompt and superuser promptfor the C shell, Bourne shell, and Korn shell. Related Documentation This manual is designed to accompany the following documents: • The Pascal 4.0 Reference Manual,...
Page 23 - README; Other Related Documentation
Preface xxiii README Files The README default directory is: /opt/SUNWspro/READMEs . This directory contains the following files: • A Pascal 4.0 README , called pascal , that describes the new features, software incompatibilities, and software bugs • A floating-point white paper, “What Every Scientis...
Page 25 - Introduction; Standards; BSD. It complies with; FIPS PUB
1 Introduction 1 This chapter gives an overview of the features of Pascal, includingcompatibility, internationalization, and licensing. It contains the followingsections: Standards Pascal is a derivative of the Berkeley Pascal system distributed with UNIX ® 4.2 BSD. It complies with FIPS PUB 109 ANS...
Page 26 - Pascal Compiler; Compatibility
2 Pascal 4.0 User’s Guide 1 Pascal Compiler The name of the Pascal compiler is pc . If given an argument file name ending with .p or .pas , pc compiles the file and leaves the result in an executable file, called a.out by default. Features Pascal includes many extensions to the standard, including t...
Page 27 - Text Editors; Text Editor; autoindent; Debuggers; dbx; XView Toolkit
Introduction 3 1 Text Editors The operating system provides two main editors: • Text Editor —A window-based text editor that runs in the OpenWindows environment. Start this tool by typing textedit at the system prompt. • vi —The standard visual display editor that offers the capabilities of both a l...
Page 28 - Internationalization; Level 1; date
4 Pascal 4.0 User’s Guide 1 Internationalization A product can support up to four levels of internationalization: • Level 1 —Allows native-language characters (such as the a-umlaut). This is referred to as the 8-bit clean model because the eighth bit in each byte isused to represent native-language ...
Page 29 - Locale; Licensing; —Does not queue request if no license is available.
Introduction 5 1 If you reset your system locale to, for example, France, and rerun the program,the output is the same. Pascal does not replace the period with a comma, theFrench decimal unit. Locale You can change your application from one native language to another bysetting the locale. For inform...
Page 31 - Pascal Programs
7 Pascal Programs 2 This chapter cites two examples that illustrate how to compile and execute aprogram. It also explains how to use the traceback facility to find out why aprogram fails. The sections are: Building a program with SPARCompiler Pascal requires three steps: 1. Writing a program in Pasc...
Page 32 - Compiling the Program; Now compile the program with
8 Pascal 4.0 User’s Guide 2 Compiling the Program Now compile the program with pc , the Pascal compiler, by typing at the system prompt: hostname% pc temp.p Pascal names the compiled version of the program a.out by default. program temperature(output) ; { Program to convert temperatures from Fahrenh...
Page 33 - Running the Program; mv
Pascal Programs 9 2 Running the Program To run the program, enter a.out at the prompt. The output of temp.p is then displayed: Renaming the Executable File It is inconvenient to have the result of every compilation in a file called a.out . If such a file already exists, it is overwritten. You can av...
Page 34 - An Interactive Pascal Program
10 Pascal 4.0 User’s Guide 2 Now run the program by typing the name of the executable file. The outputfollows: An Interactive Pascal Program In Pascal, the predefined file variable, input , is equivalent to the operating system standard input file, stdin . Similarly, the file variable, output , is e...
Page 35 - input
Pascal Programs 11 2 Compiling the Program Use the pc command to compile the program and store it in the executable file copy . Here is the command format: hostname% pc -o copy copy.p Running the Program Because the standard files input and output default to the terminal, the program simply echoes e...
Page 36 - Using the same program, but with the; Using a File Name as a File Variable; lists
12 Pascal 4.0 User’s Guide 2 Using the same program, but with the < operator to redirect input, you can print the file on the terminal: Using a File Name as a File Variable You can also redirect the output by listing the file as a file variable in theprogram statement. The Pascal library associat...
Page 37 - Where Did My Program Fail?; Using Pascal Traceback
Pascal Programs 13 2 Assuming that the file data is still in the current directory, you can compile and run the program as follows: Where Did My Program Fail? SPARCompiler Pascal can trace why a program failed; its traceback utilityfinds the routine that triggers the error. Using Pascal Traceback Pa...
Page 38 - Using a Sample Program with Segmentation Violation; which contains a segmentation violation:; Compiling and Running the Program
14 Pascal 4.0 User’s Guide 2 Using a Sample Program with Segmentation Violation A segmentation violation occurs when your program tries to reference memoryoutside your address space. The operating system detects this action andgenerates an error message. Following is an example program, SegViol.p , ...
Page 39 - ErrorInHere; Using the
Pascal Programs 15 2 In this example, ErrorInHere reported the error. The ErrorInHere procedure was called by Call1.Call2 , which was in turn called by the main program. Routine names, such as Call1.Call2 , indicate a nested routine. If Pascal cannot find the name of a routine, for example, because ...
Page 41 - The Pascal Compiler
17 The Pascal Compiler 3 The name of the Pascal compiler is pc . If you give pc a file name as an argument, and the file name ends with .p or .pas , pc compiles the file and leaves the result in an executable file, called a.out by default. The syntax of this command is: pc [ options ] filename This ...
Page 42 - Compile and Link Sequence
18 Pascal 4.0 User’s Guide 3 To identify the version number given an executable or object file created by thePascal compiler, use the following command. Compile and Link Sequence You can compile the file any.p with the following command-line: hostname% pc any.p This command actually invokes the comp...
Page 43 - Language Preprocessor
The Pascal Compiler 19 3 Figure 3-1 shows the sequence of events when you invoke pc . Figure 3-1 Organization of Pascal Compilation Language Preprocessor The cpp (1) program is the C language preprocessor. The compiler driver pc normally calls cpp (1) during the first pass of a Pascal compilation. I...
Page 44 - cpp; File Name Extensions Accepted By
20 Pascal 4.0 User’s Guide 3 See the man page for cpp (1) for information on its directives and other features. Appendix A, “Pascal Preprocessor,” describes cppas . File Name Extensions Accepted By pc Pascal source files generally use the extension .p . The compiler recognizes other file name extens...
Page 45 - ) followed by the option; Option-Passing in the Program Text; Here are four examples of how options can be passed in program text:
The Pascal Compiler 21 3 Option-Passing on the Command-Line To pass an option on the command-line, use a dash ( - ) followed by the option name. In some cases, you must supply additional information, such as a filename. For example, this command activates the listing option -l , which is off by defa...
Page 47 - If no values have been pushed onto the stack, the effect of; Options; This section describes all the
The Pascal Compiler 23 3 If no values have been pushed onto the stack, the effect of * is undefined. Figure 3-2 illustrates how options are passed in program text. Figure 3-2 Options in Program Text Options This section describes all the pc command options in alphabetical order. Unless otherwise sta...
Page 48 - binding
24 Pascal 4.0 User’s Guide 3 –a The –a option is the old style of basic block profiling for tcov . See -xprofile=tcov for information on the new style of profiling and the tcov (1) man page for more details. Also see the manual, Profiling Tools. The –a option inserts code to count how many times eac...
Page 51 - DOMAIN; name
The Pascal Compiler 27 3 The –cond option instructs pc to compile the lines in your program that begin with the %debug compiler directive. If you compile your program without –cond , pc treats lines with the %debug directive as comments. –xl runs your program through the preprocessor cppas , which h...
Page 52 - –dalign; dalign; –fast
28 Pascal 4.0 User’s Guide 3 –dalign The – dalign option instructs the compiler to generate double load and store instructions wherever possible for faster execution. All double-typed databecome double-aligned, so do not use this option when correct alignment isnot ensured. -dn (Solaris 2.x only) Th...
Page 53 - –fns; r option sets the IEEE 754 rounding mode that
The Pascal Compiler 29 3 Do not use this option for programs that depend on IEEE standard exceptionhandling; you can get different numerical results, premature programtermination, or unexpected SIGFPE signals. Note – The criteria for the -fast option vary with the compilers from SunSoft: C, C++, FOR...
Page 54 - r, compile all routines of the
30 Pascal 4.0 User’s Guide 3 The default is -fround=nearest . The meanings are the same as those for the ieee_flags subroutine. If you compile one routine with -fround= r, compile all routines of the program with the same –fround= r option; otherwise, unexpected results may occur. –ftrap= t (Solaris...
Page 55 - name option names a shared dynamic library and
The Pascal Compiler 31 3 –g The –g option instructs pc to produce additional symbol table information for dbx and debugger . With -g , the incremental linker, ild , is called, instead of ld . You can compile using both the -g and -O options. However, there are some side effects: • The next and step ...
Page 56 - –help; pathname; file
32 Pascal 4.0 User’s Guide 3 Every executable file has a list of needed shared library files. When theruntime linker links the library into an executable file, the linker copies theintrinsic name from the library into that list of needed shared library files. Ifthere is no intrinsic name of a shared...
Page 57 - directory; directory option adds directory to the
The Pascal Compiler 33 3 –L The –L option maps all keywords and identifiers to lowercase. In Pascal, uppercase and lowercase are not interchangeable in identifiers and keywords.In standard Pascal, the case is insignificant outside of character strings andcharacter constants. The –L option is most us...
Page 58 - –libmil; lib option links; –misalign
34 Pascal 4.0 User’s Guide 3 -libmieee Forces IEEE 754 style return values for math routines in exceptional cases. Insuch cases, no exception message is printed, and errno is not set. –libmil The –libmil option instructs the compiler to select the best inline templates for the floating-point option ...
Page 59 - –native
The Pascal Compiler 35 3 –native The –native option causes pc to generate code for the best floating-point hardware available on the machine you are compiling on. The -fast macro includes -native in its expansion. (Solaris 2.x only) This option is a synonym for -xtarget=native . -nocx (Solaris 1.x o...
Page 60 - boolean
36 Pascal 4.0 User’s Guide 3 -notrace The -notrace option disables runtime traceback. It is only effective when compiling the main program. –O[ level ] The –O option instructs the compiler to run the compiled program through the object code optimizer. The –O option also calls the –P option, which en...
Page 61 - csh
The Pascal Compiler 37 3 –O3 , -xO3 Same as -O2 , but optimizes the uses and definitions of external variables. Level -O3 does not trace the effects of pointer assignments. Do not use Level -O3 when compiling device drivers or programs that modify external variables from within signal handlers. –O4 ...
Page 62 - limit datasize 16M; filename; filename. The default file name for executable files is
38 Pascal 4.0 User’s Guide 3 This command causes the optimizer to try to recover if it reaches 16 megabytesof data space. This limit cannot be greater than the machine’s total available swap space, andin practice, should be small enough to permit normal use of the machine whilea large compilation is...
Page 63 - –pg; executable file, a more; –pic
The Pascal Compiler 39 3 –p and –pg The –p and –pg options instruct the compiler to produce code that counts the number of times each routine is called. The profiling is based on a periodicsample taken by the system, rather than by line counters. Using the -p Option To generate an execution profile ...
Page 64 - –Qoption; sourcetype, which can be one of the following:
40 Pascal 4.0 User’s Guide 3 –Qoption The –Qoption passes an option to the program. The option value must be appropriate to that program and can begin with a plus or minus sign. Theprogram value can be either as (1) (Solaris 1.x only), fbe (1) (Solaris 2.x only), cpp (1), cppas , inline (1), iropt ,...
Page 66 - WITH
42 Pascal 4.0 User’s Guide 3 The compiler issues warnings at the end of the procedure where the recordvariables are defined, that is, when some of the fields are definitely not set.However, no warnings are issued if fields are used in the source before they areinitialized, as the control flow may be...
Page 70 - write; –sb; –sbfast
46 Pascal 4.0 User’s Guide 3 –S The –S option compiles the program and outputs the assembly language in the file, sourcefile. s . For example, the following command places the assembly language translation of rmc.p in the file rmc.s . No executable file is created. hostname% pc –S rmc.p –s[ level ] ...
Page 71 - dir
The Pascal Compiler 47 3 -tc The -tc option instructs the compiler to generate pc3 stab information that allows cross-module type checking. This option can be used for two purposes: • To check for any name conflicts that your program may have with thestandard libraries with which it is to be linked,...
Page 72 - –time
48 Pascal 4.0 User’s Guide 3 –time The –time option instructs the compiler to report execution performance statistics for the various compilation passes. Here is some sample output;some spaces have been removed so the output would fit on the page. Each line begins with the name of the compiler pass....
Page 73 - a option limits the set of instructions the
The Pascal Compiler 49 3 –U name The –U option removes any initial definition of the cpp (1) symbol name. See cpp (1) for more information. You cannot use this option with the -xl option. –V The –V option prints the version number of each compilation pass. –V0 and –V1 The –V0 and –V1 options turn on...
Page 74 - generic
50 Pascal 4.0 User’s Guide 3 a must be one of: generic , v7 , v8 , v8a , v8plus , v8plusa . Although this option can be used alone, it is part of the expansion of the xtarget option; its primary use is to override a value supplied by the xtarget option. This option limits the instructions generated ...
Page 77 - c option defines the cache properties for use by
The Pascal Compiler 53 3 -xcache= c (Solaris 2.x only) The -xcache= c option defines the cache properties for use by the optimizer. c must be one of the following: • generic • s1 / l1 / a1 • s1 / l1 / a1 : s2 / l2 / a2 • s1 / l1 / a1 : s2 / l2 / a2 : s3 / l3 / a3 The si / li / ai are defined as foll...
Page 78 - specifies the following:
54 Pascal 4.0 User’s Guide 3 Example: -xcache=16/32/4:1024/32/1 specifies the following: -xchip= c (Solaris 2.x only) The -xchip= c option specifies the target processor for use by the optimizer. c must be one of: generic , old , super , super2 , micro , micro2 , hyper , hyper2 , powerup , ultra Alt...
Page 79 - –xF
The Pascal Compiler 55 3 -xcg89 Same as -cg89 . -xcg92 Same as -cg92 . –xF (Solaris 2.x only) The –xF option enables performance analysis of the executable file using the SPARCworks Performance Analyzer and Debugger. This optionalso causes the assembler to generate some debugging information in theo...
Page 80 - xildon
56 Pascal 4.0 User’s Guide 3 -xildoff (Solaris 2.x only) Turns off the incremental linker and forces the use of ld . This option is the default if you do not use the -g option, or you do not use the -G option, or any source files are present on the command line. Override thisdefault by using the -xi...
Page 81 - –xMerge
The Pascal Compiler 57 3 -xlibmopt Uses a math routine library optimized for performance. The results may beslightly different than those produced by the normal math library. This optionis implied by the -fast option. –xlicinfo The -xlicinfo option returns information about the licensing system. In ...
Page 82 - Same as
58 Pascal 4.0 User’s Guide 3 Generates the highest level of optimization. Uses optimization algorithms thattake more compilation time or that do not have as high a certainty ofimproving execution time. Optimization at this level is more likely to improveperformance if it is done with profile feedbac...
Page 84 - option specifies the usage of registers for the
60 Pascal 4.0 User’s Guide 3 -xregs= r (Solaris 2.x only) The -xregs= r option specifies the usage of registers for the generated code. r is a comma-separated list that consists of one or more of the following:[ no% ] appl , [ no% ] float . Example: -xregs=appl,no%float The default is -xregs=appl,fl...
Page 85 - –xs; —This is the newer (and default) way of loading symbol tables.
The Pascal Compiler 61 3 –xs (Solaris 2.x only) The -xs option disables Auto-Read for dbx in case you cannot keep the .o files around. This option passes the -s option to the assembler and the linker. • No Auto-Read —This is the older way of loading symbol tables. • The compiler instructs the linker...
Page 86 - t option specifies the target system for the
62 Pascal 4.0 User’s Guide 3 -xspace (Solaris 2.x only) The -xspace option does no optimizations that increase the code size. Example: Do not unroll loops. -xtarget= t (Solaris 2.x only) The -xtarget= t option specifies the target system for the instruction set and optimization. t must be one of: na...
Page 87 - Each specific value for
The Pascal Compiler 63 3 very important. This is especially true when running on the newer SPARCprocessors. However, for most programs and older SPARC processors, theperformance gain is negligible and a generic specification is sufficient. Each specific value for -xtarget expands into a specific set...
Page 92 - includefile; Using Program Units and Module Units; Program unit
68 Pascal 4.0 User’s Guide 4 The actual includefile looks like this: In this example, the include file contains the entire program. In reality, an include file probably contains a set of variable or procedure declarations. include files are often used when a set of declarations needs to be shared am...
Page 93 - extern; Module unit; external; Compiling with Units
Program Construction and Management 69 4 The body of the procedure say_hello is not defined in this program unit, but the program unit does contain a declaration of the interface to theprocedure. The keyword extern declares that say_hello is declared in a module unit. 1 • Module unit —This unit can ...
Page 94 - Using Units and Header Files
70 Pascal 4.0 User’s Guide 4 You can also separate the compilation and linking or loading steps, as follows: hostname% pc program_unit.p -c hostname% pc module_unit.p -c hostname% pc program_unit.o module_unit.o In this case, you call pc on each unit with the “compile only” option ( -c ), which prod...
Page 95 - Sharing Variables Between Units
Program Construction and Management 71 4 In a real program, header.h would probably contain many declarations and would be included in several modules. Aside from routine declarations,header files often contain constant, type, and variable declarations. Sharing Variables Between Units Variables that...
Page 96 - Here is a program unit that declares a variable:
72 Pascal 4.0 User’s Guide 4 Here is a program unit that declares a variable: Here is a module unit that declares a variable with the same name: program program_unit3 (output); var x : integer; procedure say_hello; external; begin for x := 1 to 5 do say_hello end. module module_unit3; var x : intege...
Page 98 - Libraries; option. You can then link the
74 Pascal 4.0 User’s Guide 4 Libraries You can use a module unit as a library of useful functions. The simplest wayto do so is to create a source file containing the definitions of your libraryroutines and then compile it using the -c option. You can then link the resulting .o file to any number of ...
Page 99 - Separate Compilation
75 Separate Compilation 5 This chapter describes how to compile Pascal programs in separate units.Chapter 4, “Program Construction and Management,” gives an introduction tothe concepts in this chapter. Following are the sections: In separate compilation, a program is divided into several units that ...
Page 100 - Using Program Units; Using Module Units; module; Sharing Variables and Routines Across Multiple Units; include
76 Pascal 4.0 User’s Guide 5 Using Program Units The program unit is the source program with the program header. It has thefollowing syntax: < program unit > ::= < program heading > < declaration list > < program body > Each program you write can have only one program unit. T...
Page 101 - Sharing Public Variables
Separate Compilation 77 5 Compiling without the -xl Option There are three ways of sharing variables and routines across units when youcompile your program without the –xl option. Sharing Public Variables If you declare a variable in two or more separate units and the variable is public in both plac...
Page 102 - Using
78 Pascal 4.0 User’s Guide 5 Using extern Option to Share Routines If a program or module calls a procedure not defined in that unit, you mustdeclare it with either the extern or external routine option. For instance, in the previous example, the procedure proc is defined in shrvar_mod.p , but used ...
Page 104 - Declarations
80 Pascal 4.0 User’s Guide 5 Using the -xl Option When you use the – xl option, variables and top-level procedures and functions declared in the program unit default to private . Look at the difference when you compile and execute shrvar_prog.p and shrvar_mod.p with – xl . See the source code in “Sh...
Page 106 - define; Variable Attribute; This example makes
82 Pascal 4.0 User’s Guide 5 Using the define Variable Attribute This example makes global public using the define attribute of the variable declaration. The program unit, defvar_prog.p program defvar_prog; var global: extern integer; procedure proc; external; begin global := 1; writeln('From MAIN, ...
Page 107 - Declaration
Separate Compilation 83 5 Using the define Declaration This example defines global in the module defvar_mod2 using the define declaration. The advantage of using the define declaration over the define variable attribute is that the define declaration can be easily converted to use include files. The...
Page 108 - Files
84 Pascal 4.0 User’s Guide 5 Using include Files In the following example, the extern declaration for the variable global is in the include file, inc_prog2.p , and is therefore included in both files. The define declaration in file inc_mod2.p cancels the extern definition. The module unit, defvar_mo...
Page 110 - In the previous example, the
86 Pascal 4.0 User’s Guide 5 Using extern In the previous example, the extern definition for variables is put into an include file and then shared. You can do the same for the extern procedure definition. In doing so, you must also declare the variable with a define declaration in the module that de...
Page 111 - Sharing Declarations in Multiple Units; FORTRAN; external c
Separate Compilation 87 5 Sharing Declarations in Multiple Units Using extern and external directives for procedure and function declarations, you can optionally specify the source language of a separatelycompiled procedure or function. For example, extern fortran directs the compiler to generate ca...
Page 113 - The C–Pascal Interface; acc; Compilation of Mixed-Language Programs; You must use the compiler option
89 The C–Pascal Interface 6 This chapter describes how to mix C and Pascal modules in the same program.It contains the following sections: The examples in this chapter assume that you are using the ANSI C compiler.To invoke ANSI C: • On the Solaris 1.x environment, use the acc command • On the Solar...
Page 114 - Compatibility of Types for C and Pascal
90 Pascal 4.0 User’s Guide 6 The -c option produces an unlinked object file. The -calign option causes pc to use C-like data formats for aggregate objects. When you compile a Pascal main routine that calls C, you don’t have to useany special options, but the -calign option is again useful. The C obj...
Page 115 - Precautions with Compatible Types
The C–Pascal Interface 91 6 Precautions with Compatible Types This section describes the precautions you should take when working withcompatible types. The shortreal Type The Pascal shortreal and C float compatibility works if you pass by reference. See “Value Parameters” on page 112 for examples th...
Page 116 - Array Indexes; Incompatibilities; Enumerated Types; char
92 Pascal 4.0 User’s Guide 6 Array Indexes Pascal array indexes can start at any integer; C array indexes always start atzero. Aggregate Types Aggregate types include arrays, varying arrays, sets, strings, alphas, records,and variant records. Pascal aggregate types may require alignment and layout a...
Page 117 - Pascal Set Types; General Parameter Passing in C and Pascal; A few general rules apply to parameter passing:; Procedure Calls: C–Pascal; Here are examples of how a C main program calls a Pascal procedure:
The C–Pascal Interface 93 6 Pascal Set Types In Pascal, a set type is implemented as a bit vector, which is similar to a Cshort-word array, where each short-word contains two bytes. Thus, sets arebit-vectors, and they are allocated in multiples of 16 bits. To find out the sizeof a set, enter the fol...
Page 118 - Variable Parameters
94 Pascal 4.0 User’s Guide 6 Variable Parameters Pascal passes all variable parameters by reference, which C can do, too. The C main program, SampMain.c . Note the procedure definition and call. #include <stdio.h> extern void Samp(int *, double *); int main (void) { int i ; double d ; Samp(&am...
Page 119 - Simple Types without; Without
The C–Pascal Interface 95 6 Simple Types without –xl Without -xl , simple types match, as in the following example: The Pascal procedure, SimVar.p procedure SimVar( var t, f: boolean; var c: char; var si: integer16; var i: integer; var sr: shortreal; var r: real); begin t := true; f := false; c := '...
Page 120 - Simple Types with
96 Pascal 4.0 User’s Guide 6 Simple Types with –xl With the -xl option, the Pascal real must be paired with a C float , and the Pascal integer must be paired with a C short int . Strings of Characters The C counterpart to the Pascal alfa and string types are arrays; C passes all arrays by reference....
Page 121 - Fixed Arrays
The C–Pascal Interface 97 6 Fixed Arrays For a fixed array parameter, pass the same type and size by reference, asshown in the following example: The C main program, StrVarMain.c #include <stdio.h> #include <string.h> struct TVarLenStr { int nbytes; char a[25]; }; extern void StrVar(char...
Page 122 - option to compile the Pascal code, that difference with C is
98 Pascal 4.0 User’s Guide 6 Although it does not apply in this example, arrays of aggregates in Pascalhave, by default, a size that is always a multiple of four bytes. When you usethe -calign option to compile the Pascal code, that difference with C is eliminated. The following example illustrates ...
Page 124 - You can pass any size array to a Pascal procedure expecting a
100 Pascal 4.0 User’s Guide 6 The univ Arrays You can pass any size array to a Pascal procedure expecting a univ array, although there is no special gain in doing so, because there is no type or sizechecking for separate compilations. However, if you want to use an existingPascal procedure that has ...
Page 125 - Conformant Arrays
The C–Pascal Interface 101 6 Conformant Arrays For single-dimension conformant arrays, pass upper and lower bounds, placedafter the declared parameter list. If the array is multidimensional, passelement widths as well, one element width for each dimension, except the lastone. See this example: One b...
Page 128 - If; lb; Example 3: Array of Characters
104 Pascal 4.0 User’s Guide 6 If wc is the width of the smallest element, as determined by sizeof() , then the width of the next largest element is the number of those smaller elementsin the next larger element multiplied by wc . width of next largest element = (ub - lb + 1) * wc In general, ( lb , ...
Page 129 - Records and Structures; in
The C–Pascal Interface 105 6 Records and Structures In most cases, a Pascal record describes the same objects as its C structureequivalent, provided that the components have compatible types and aredeclared in the same order. The compatibility of the types depends mostly onsize and alignment. For mo...
Page 131 - Consider this example:
The C–Pascal Interface 107 6 Consider this example: The Pascal routine, DayWeather.p type TDayWeather = record TDay: array [0..8] of char; TWeather: array [0..20] of char; end; TDayWeatherArray = array [0..1] of TDayWeather; procedure DayWeather(var W: TDayWeatherArray; var WeatherSize: integer); be...
Page 132 - When you compile the Pascal routine without using the; Variant Records
108 Pascal 4.0 User’s Guide 6 When you compile the Pascal routine without using the -calign option, the program does not work correctly. Variant Records C equivalents of variant records can sometimes be constructed, although thereis some variation with architecture and sometimes a need to adjust ali...
Page 134 - Pascal Set Type; The nth element in a set
110 Pascal 4.0 User’s Guide 6 Pascal Set Type In Pascal, a set type is implemented as a bit vector, which is similar to a Cshort-word array. Direct access to individual elements of a set is highlymachine-dependent and should be avoided. In Pascal, bits are numbered within a byte from the most signif...
Page 135 - Pascal; The Pascal
The C–Pascal Interface 111 6 Pascal intset Type The Pascal intset type is predefined as set of [0..127] . A variable of this type takes 16 bytes of storage. The Pascal procedure, IntSetVar.p , which has an intset of the elements [1, 3, 7, 8] procedure IntSetVar(var s: intset); begin s := [1, 3, 7, 8...
Page 136 - Value Parameters; There are three types of value parameters in Pascal.
112 Pascal 4.0 User’s Guide 6 Value Parameters There are three types of value parameters in Pascal. Simple Types without –xl Without –xl , simple types match, as in the following example: The Pascal procedure, SimVal. p . t , f , c , i , r , and s are value parameters . procedure SimVal( t, f: boole...
Page 138 - Arrays; univ
114 Pascal 4.0 User’s Guide 6 Arrays Since C cannot pass arrays by value, it cannot pass strings of characters, fixedarrays, or univ arrays by value. Conformant Arrays Pascal passes all value parameters on the stack or in registers, except for valueconformant array parameters, which are handled by c...
Page 139 - Function Return Values; Simple Types; The simple types pass in a straightforward way, as follows:
The C–Pascal Interface 115 6 Function Return Values Function return values match types the same as with parameters, and theypass in much the same way. Simple Types The simple types pass in a straightforward way, as follows: The commands to compile andexecute ChrCAVal.p and ChrCAValMain.c with -calig...
Page 140 - Input and Output; Also, in the C main program just before exit, add the following line:
116 Pascal 4.0 User’s Guide 6 Input and Output If your C main program calls a Pascal procedure that does I/O, then includethe following code in the C main program before you call the Pascal procedure: Also, in the C main program just before exit, add the following line: See this example: The command...
Page 141 - Procedure Calls: Pascal–C; Simple types pass in a straightforward manner, as follows:
The C–Pascal Interface 117 6 Procedure Calls: Pascal–C This section parallels the section, “Procedure Calls: C–Pascal” on page 93.Earlier comments and restrictions also apply here. Variable Parameters Pascal passes all variable parameters by reference, which C can do, too. Simple Types Simple types ...
Page 142 - Strings of Characters
118 Pascal 4.0 User’s Guide 6 Strings of Characters The alfa and string types pass simply; varying strings are more complicated. All pass by reference. The Pascal main program, SimRefMain.p program SimRefMain(output); var t, f: boolean; c: char; si: integer16; i: integer; sr: shortreal; r: real; pro...
Page 144 - mktemp
120 Pascal 4.0 User’s Guide 6 Avoid constructs that rely on strings being in static variable storage. Forexample, you could use mktemp (3) in Pascal as follows: This use is incorrect, since mktemp() modifies its argument. Instead, use the C library routine strncpy() (see string (3)) to copy the stri...
Page 147 - The following example uses a single-dimension array:
The C–Pascal Interface 123 6 The -calign option is not needed for this example, but may be necessary if the array parameter is an array of aggregates. Conformant Arrays For single-dimension conformant arrays, pass upper and lower bounds placedafter the declared parameter list. If the array is multid...
Page 150 - Following are some examples:
126 Pascal 4.0 User’s Guide 6 Following are some examples: The C function, VarRec.c struct vlr { char tag; union { struct { char ch1, ch2; } a_var; struct { char flag; } b_var; struct { int ALIGN; } c_var; } var_part; }; void VarRec(struct vlr *x) { if (x->var_part.a_var.ch1 == 'a') x->var_par...
Page 151 - Non-Pascal Procedures; nonpascal
The C–Pascal Interface 127 6 The -calign option is not needed in the previous example, but may be necessary if the record contains aggregates. Non-Pascal Procedures When you use the -xl option in compiling Pascal code, you can use the nonpascal keyword to declare that an external procedure is writte...
Page 155 - Parameters That Are Pointers to Procedures
The C–Pascal Interface 131 6 Parameters That Are Pointers to Procedures Pascal has a special type that is a pointer to a procedure. A variable of thistype can be used as a parameter, as follows: The C function, RetReal.c double RetReal(double *x) { return(*x + 1.0); } The Pascal main program, RetRea...
Page 156 - Procedures and Functions as Parameters
132 Pascal 4.0 User’s Guide 6 Procedures and Functions as Parameters It is probably clearer to pass a pointer to a procedure than to pass theprocedure name itself. See “Procedure Calls: Pascal–C” on page 117. A procedure or function passed as an argument is associated with a static linkto its lexica...
Page 157 - Global Variables in C and Pascal
The C–Pascal Interface 133 6 functions can be passed to other languages as arguments, the static links for allprocedure or function arguments are placed after the end of the conformantarray bounds pairs, if any. Routines in other languages can be passed to Pascal; a dummy argument mustbe passed in t...
Page 158 - File-Passing Between Pascal and C
134 Pascal 4.0 User’s Guide 6 File-Passing Between Pascal and C You can pass a file pointer from Pascal to C, then have C do the I/O, as in: The commands to compile andexecute GloVar.p and GloVarMain.c without –xl . With -xl , the Pascal integer must be paired with a C short int and declared public ...
Page 161 - CC
137 The C++–Pascal Interface 7 This chapter describes how to mix C++ and Pascal modules in the sameprogram. It contains the following sections: Sample Interface You must use the compiler option -lpc when you use CC to link a C++ main routine that calls Pascal. -lpc denotes linking with the Pascal ru...
Page 162 - Compatibility of Types for C++ and Pascal; language construct. One common way to
138 Pascal 4.0 User’s Guide 7 Compatibility of Types for C++ and Pascal Table 6-1 and Table 6-2 on page 90 list the default sizes and alignments ofcompatible types for C and Pascal. They apply to C++ as well. C++ Name Encoding To implement function overloading and type-safe linkage, the C++ compiler...
Page 163 - Arguments Passed by Reference
The C++–Pascal Interface 139 7 Arguments Passed by Reference C++ arguments can be passed by reference. This section describes how theywork with Pascal. The C++ main program, SampMain.cc #include <stdio.h> extern "C" void Samp (int&, double&); int main(void) { int i; double d; S...
Page 164 - Simple Types without the; Without the
140 Pascal 4.0 User’s Guide 7 Simple Types without the -xl Option Without the -xl option, simple types match, as in the following example: The Pascal procedure, SampRef , in the file, Samp.p procedure SamRef ( var t, f: boolean; var c: char; var i: integer; var s: integer16; var r: shortreal; var d:...
Page 165 - With the
The C++–Pascal Interface 141 7 Simple Types with the -xl Option With the -xl option, the Pascal real must be paired with a C++ float ; the Pascal integer must be paired with a C++ short int . The C++ main program, SamRefMain.cc #include <stdio.h> extern "C" void SamRef ( char &, ch...
Page 174 - Arguments Passed by Value
150 Pascal 4.0 User’s Guide 7 Arguments Passed by Value C++ arguments can be passed by value. In this section, we describe how theywork with Pascal. When you compile the Pascalroutine without the -calign option, the program does not work correctly. hostname% pc -c DayWeather.p hostname% CC DayWeathe...
Page 178 - Type
154 Pascal 4.0 User’s Guide 7 Type shortreal Input and Output The Pascal function, RetShortReal.p function RetShortReal (r: shortreal): shortreal; begin RetShortReal := r + 1.0 end; The C++ main program, RetShortRealMain.cc #include <stdio.h> #include <math.h> extern "C" float Re...
Page 180 - Simple Types Passed by Reference
156 Pascal 4.0 User’s Guide 7 Simple Types Passed by Reference Simple types pass in a straightforward manner, as follows: The C++ function, SimRef.cc extern "C" void SimRef ( char &t, char &f, char &c, int &i, short &s, float &r, double &d) { t = 1; f = 0; c = 'z'...
Page 184 - The following example shows how to pass simple types:
160 Pascal 4.0 User’s Guide 7 The following example shows how to pass simple types: The C++ function, RetReal.cc extern "C" double RetReal (double &x) { return (x + 1.0); } The Pascal main program, RetRealMain.p program RetRealMain (output); var r, s: real; function RetReal (var x: real)...
Page 187 - The FORTRAN–Pascal Interface; –lpfc
163 The FORTRAN–Pascal Interface 8 This chapter describes how to mix FORTRAN 77 and Pascal modules in thesame program. It contains the following sections: Compiler Mixed-Language Programs When you compile with the -v (verbose) option, the Pascal driver brings in the runtime libraries for the main mo...
Page 188 - Compatibility of Types for FORTRAN and Pascal
164 Pascal 4.0 User’s Guide 8 Specify –lpfc on the command-line before –lpc . For example: The -c option to pc produces an unlinked object file. When you compile a Pascal main routine that calls FORTRAN, you must usethe compiler options –lpfc and –lF77 . The –lF77 option links the FORTRAN object lib...
Page 189 - xl
The FORTRAN–Pascal Interface 165 8 Table 8-2 lists the default sizes and alignments of compatible types forFORTRAN and Pascal with the - xl option: Precautions with Compatible Types This section describes the precautions you must take when working withcharacter strings and array indexes. Table 8-1 D...
Page 190 - Character Strings; Pascal enumerated types have no comparable type in FORTRAN.
166 Pascal 4.0 User’s Guide 8 Character Strings There are some precautions to take with character strings regarding the nullbyte, passing by value, and static storage: • Set the byte count to zero before calling Pascal with a null varying string,because that is what Pascal assumes about such strings...
Page 191 - General Parameter-Passing in FORTRAN and Pascal; A few general rules apply to passing parameters:
The FORTRAN–Pascal Interface 167 8 Pascal Set Types In Pascal, a set type is implemented as a bit vector, which is similar to aFORTRAN 16-bit word. Direct access to individual elements of a set is highlymachine-dependent and should be avoided. Multidimensional Arrays Pascal multidimension arrays are...
Page 192 - Pascal passes all; With
168 Pascal 4.0 User’s Guide 8 Procedure Calls: FORTRAN-Pascal Here are examples of how a FORTRAN main program calls a Pascal procedure. Variable Parameters Pascal passes all var parameters by reference, FORTRAN’s default. Simple Types without the –xl Option With var parameters, simple types match. T...
Page 193 - See the following example:
The FORTRAN–Pascal Interface 169 8 See the following example: The Pascal procedure, SimVar.p procedure simvar_(var t, f: boolean; var c: char; var i: integer; var r: real; var si: integer16; var sr: shortreal); begin t := true; f := false; c := 'z'; i := 9; r := 9.9; si := 9; sr := 9.9 end; { simvar...
Page 194 - Simple Types with the
170 Pascal 4.0 User’s Guide 8 Simple Types with the –xl Option When you pass the -xl option, the Pascal data type real must be paired with a FORTRAN data type real ; the Pascal data type integer must be paired with a FORTRAN data type, integer*2 . Strings of Characters The FORTRAN counterpart to the...
Page 198 - Example 2: Array of Characters
174 Pascal 4.0 User’s Guide 8 Example 1: Single-Dimension Array Example 2: Array of Characters The Pascal procedure, IntCA.p . Pascal passes the bounds by value. procedure intca_(var a: array [lb..ub: integer] of integer); begin a[1] := 1; a[2] := 2 end; { intca_ } The FORTRAN main program, IntCAmai...
Page 203 - The Pascal set type is incompatible with FORTRAN.
The FORTRAN–Pascal Interface 179 8 Pascal Set Type The Pascal set type is incompatible with FORTRAN. Pascal intset Type The Pascal intset type is predefined as set of [0..127] . A variable of this type takes a minimum of 16 bytes of storage. The Pascal procedure, IntSetVar.p , which has an intset of...
Page 204 - In general, Pascal passes value parameters on the stack.
180 Pascal 4.0 User’s Guide 8 Value Parameters In general, Pascal passes value parameters on the stack. Simple Types without the –xl Option Without the -xl option, simple types match. The commands to compile andexecute IntSetVar.p and IntSetVarmain.f . The output of this example dependson the archit...
Page 207 - Pointers; Pointers are easy to pass, as shown in the following example:
The FORTRAN–Pascal Interface 183 8 Pointers Pointers are easy to pass, as shown in the following example: Pascal procedure, ChrCAx.p procedure chrca_ ( a: array [lb..ub:integer] of char) ; begin a[0] := 'T' ; a[13] := 'o' ; end; { chrca_ } The FORTRAN main program, ChrCAmain.f character s*16 data s ...
Page 209 - There is no problem with returning a
The FORTRAN–Pascal Interface 185 8 Simple Types The simple types pass in a straightforward way, as follows: Type shortreal There is no problem with returning a shortreal function value between Pascal and FORTRAN. As in the previous example, it can be passed exactly,with the Pascal shortreal type mat...
Page 213 - Character Dummy Arguments; extern fortran
The FORTRAN–Pascal Interface 189 8 Character Dummy Arguments When you call FORTRAN 77 routines with character dummy arguments fromPascal programs—that is, routines in which string arguments are specified as character*(*) in the FORTRAN source, there is no explicit analogue in Pascal. So, if you try ...
Page 214 - The following example illustrates this method:
190 Pascal 4.0 User’s Guide 8 The following example illustrates this method: The Pascal program, sun.pas program Test(input,output); var s : string; procedure mygrout_(var prompt :string; length :integer32); external; begin writeln('Starting...'); s := 'Trio Jeepy'; mygrout_(s, 8); writeln('Ending.....
Page 218 - Records and structures pass as follows:
194 Pascal 4.0 User’s Guide 8 Records and Structures Records and structures pass as follows: The FORTRAN subroutine, StruChr.f subroutine StruChr ( vls ) structure /VarLenStr/ integer nbytes character a*25 end structure record /VarLenStr/ vls vls.a(1:5) = 'oyvay' vls.nbytes = 5 return end The Pascal...
Page 225 - The simple types pass in a straightforward way, as in this example:
The FORTRAN–Pascal Interface 201 8 Function Return Values Function return values match types the same as with parameters, and theypass in much the same way. Simple Types The simple types pass in a straightforward way, as in this example: The commands to compile andexecute PassPtr.f and PassPtrmain.p...
Page 226 - You can return a; Routines as Parameters
202 Pascal 4.0 User’s Guide 8 Type shortreal You can return a shortreal function value between Pascal and FORTRAN. Pass it exactly as in the previous example, with the Pascal shortreal type matching the FORTRAN real type (without -xl ). Routines as Parameters If the passed procedure is a top-level p...
Page 229 - Error Diagnostics; Appendix B, “Error Messages,” lists in numerical order all the error; Illegal Characters; Characters such as
205 Error Diagnostics 9 This chapter discusses the errors you may come across while writing softwareprograms with Pascal. It contains the following sections: Note – Appendix B, “Error Messages,” lists in numerical order all the error messages generated by Pascal. Compiler Syntax Errors Here are some...
Page 230 - String Errors
206 Pascal 4.0 User’s Guide 9 Most nonprinting characters in your input are also illegal, except in characterconstants and character strings. Except for the tab and formfeed characters,which are used to format the program, nonprinting characters in the input fileprint as the character ? in your list...
Page 232 - Undefined or Improper Identifiers; Expected Symbols and Malformed Constructs
208 Pascal 4.0 User’s Guide 9 Undefined or Improper Identifiers If an identifier is encountered in the input but is undeclared, the error recoverymechanism replaces it with an identifier of the appropriate class. Further references to this identifier are summarized at the end of thecontaining proced...
Page 234 - Compiler Semantic Errors; Format of the Error Diagnostics; end; Incompatible Types
210 Pascal 4.0 User’s Guide 9 Compiler Semantic Errors The following sections explain the typical formats and terminology used inPascal error messages. Format of the Error Diagnostics In the example program above, the error diagnostics from the Pascal compilerinclude the line number in the text of t...
Page 236 - Scalar Error Messages; as other than a text file.; Expression Diagnostics
212 Pascal 4.0 User’s Guide 9 Scalar Error Messages Error messages stating that scalar (user-defined) types cannot be read from andwritten to files are often difficult to interpret. In fact, if you define: type color = (red, green, blue) standard Pascal does not associate these constants with the st...
Page 237 - This program generates the following error messages:
Error Diagnostics 213 9 This program generates the following error messages: program expr_example(output); var a: set of char; b: Boolean; c: (red, green, blue); p: ^ integer; A: alfa; B: packed array [1..5] of char; begin b := true; c := red; new(p); a := []; A := 'Hello, yellow'; b := a and b; a :...
Page 238 - Type Equivalence; produces the following diagnostic messages:
214 Pascal 4.0 User’s Guide 9 Type Equivalence The Pascal compiler produces several diagnostics that generate the followingmessage: non-equivalent types In general, Pascal considers types to be the same only if they derive from thesame type identifier. Therefore, the following two variables have dif...
Page 239 - Alternatively, you could use the declaration:; Unreachable Statements
Error Diagnostics 215 9 To make the assignment statement work, you must declare a type and use it todeclare the variables, as follows: Alternatively, you could use the declaration: The assignment statement then works. Unreachable Statements Pascal flags unreachable statements. Such statements usuall...
Page 241 - If you receive an; Runtime Errors; Following is a list of runtime errors that Pascal generates:
Error Diagnostics 217 9 If you declare a label but never use it, Pascal gives you a warning. This is trueeven for a label declared in global scope. Compiler Panics, I/O Errors One class of error that rarely occurs, but which causes termination of allprocessing when it does, is a panic. A panic indic...
Page 242 - > : Bad data found on varying of char read
218 Pascal 4.0 User’s Guide 9 < filename > : Bad data found on enumerated read < filename > : Bad data found on integer read < filename > : Bad data found on real read < filename > : Bad data found on string read < filename > : Bad data found on varying of char read <...
Page 245 - The XView Toolkit; The sections in this chapter are:
221 The XView Toolkit 10 This chapter introduces the XView programmer ’s toolkit, a part of the XViewapplication programmer ’s interface (API). It assumes you are familiar withXView windows as a user, and introduces XView from a programmer ’s pointof view. For details, see the XView Programming Manu...
Page 246 - Tools
222 Pascal 4.0 User’s Guide 10 Tools This kit is a collection of functions. The runtime system is based on eachapplication having access to a server-based Notifier, which distributes input tothe appropriate window, and a Window Manager, which manages overlappingwindows. There is also a Selection Ser...
Page 247 - Pascal Interface
The XView Toolkit 223 10 with the root being the class from which all others are descended. In theXView toolkit, the root is the class Generic Object, which has no data fields andno methods. Each descendant of Generic Object is specialized in some way,perhaps with additional data fields or methods. ...
Page 248 - Compiling with Libraries; pxview; Header Files; Names; Attribute Procedures
224 Pascal 4.0 User’s Guide 10 Compiling with Libraries Most XView procedures you call are in the libraries pxview , xview , and X11 . To compile an XView program, link the libraries, in order. For example: hostname% pc my_pascal.p -lpxview -lxview -lolgx -lX11 Header Files The header files define t...
Page 249 - set; Attribute Lists
The XView Toolkit 225 10 Instead of these routines, the Pascal interface to XView defines a separateroutine to get and set each attribute. • set —The routine to set an attribute is called set_ attrname. Each set routine is a procedure, and takes as its first argument the object for whichthe attribut...
Page 250 - ns; Handles; Scrollbar
226 Pascal 4.0 User’s Guide 10 Example calls are: The lists for Attr_avlist are created by functions that have the following names: attr_create_list_ n () attr_create_list_ ns () • The n indicates the number of arguments the routine accepts. • The number of arguments can be 1-16. • The routines endi...
Page 251 - Coding Fragment; bar; Conversion of C to Pascal; An Example; The Problem
The XView Toolkit 227 10 Coding Fragment Here is an example that illustrates the style of programming with the XViewinterface in Pascal. This program: • Creates a vertical scrollbar with a view length of 100 pixels • Changes the view length to 200 pixels • Destroys the scrollbar In this example: • b...
Page 252 - The Straightforward Part; The More Complex Parts; Boolean
228 Pascal 4.0 User’s Guide 10 The Straightforward Part —You can use the following items of information as you find them in the manual, with no change: • The XView procedure names • The XView object names • The XView object data types (except Boolean , see the following section) The More Complex Par...
Page 253 - Sample Translation of an XView Function to Pascal; If you translate the entry to Pascal, it means:
The XView Toolkit 229 10 Sample Translation of an XView Function to Pascal In the section, “Summary of Procedures and Macros,” in the XViewProgramming Manual, is the following entry: If you translate the entry to Pascal, it means: • Leave the object data type, Textsw , as is. • Since the function re...
Page 254 - Sample Program; The following program,
230 Pascal 4.0 User’s Guide 10 Sample Program The following program, xview.p , makes a window: To compile xview.p and link in the necessary libraries, use the following command-line. Replace local_library_path with the path for the Pascal XViewlibraries on your system. hostname% pc -I local_library_...
Page 255 - Menu Demo Program; Here is a more complicated program,
The XView Toolkit 231 10 Menu Demo Program Here is a more complicated program, menu_demo.p , that makes a window and a panel with a menu button. The choices displayed are: Option 1, Option2,and Option 3. program MenuDemo(output); #include "stddefs_p.h" #include "attrgetset_p.h" var b...
Page 256 - To compile
232 Pascal 4.0 User’s Guide 10 To compile menu_demo.p and link in the necessary libraries, use the following command-line: hostname% pc menu_demo.p -Ipascal_xview_include_path \ -Lpascal_xview_include_path -lpxview -lxview -lolgx -lX11 Now run the executable file: hostname% a.out base_frame := xv_cr...
Page 257 - Math Libraries
233 Math Libraries 11 This chapter describes how to use the libm and libsunmath functions in Pascal programs. The math libraries are always accessible from a Pascalprogram because the Pascal compiler driver pc calls ld , the linker and loader, with the -lsunmath -lm options. If you compile Pascal pr...
Page 258 - Contents of the Math Libraries
234 Pascal 4.0 User’s Guide 11 Contents of the Math Libraries Altogether, there are three math libraries: • libm.a —A set of functions required by the various standards to which the operating system conforms • libm.so —(Solaris 2.x only) The shared version of libm.a • libsunmath.a —A set of function...
Page 260 - IEEE Support Functions; This section describes the IEEE support functions, including
236 Pascal 4.0 User’s Guide 11 The following Pascal program is an example of how to use math functions. IEEE Support Functions This section describes the IEEE support functions, including ieee_functions() , ieee_values() , and ieeee_retrospective() . program TestLibm(output); #include <math_p.h&g...
Page 261 - The functions described in
Math Libraries 237 11 ieee_functions() The functions described in ieee_functions (3M) provide capabilities either required by the IEEE standard or recommended in its appendix. Example: ieee_values() IEEE values, such as infinity, NaN, minimum and maximum positive floating-point numbers, are provided...
Page 262 - SPARC Libraries
238 Pascal 4.0 User’s Guide 11 ieee_retrospective() The libm function ieee_retrospective() prints to stderr information about unrequited exceptions and nonstandard IEEE modes. Pascal programscall ieee_retrospective() on exit by default. SPARC Libraries The libm and libsunmath libraries also contain:...
Page 263 - Arithmetic Exceptions; Following are the five types of IEEE floating-point exceptions:; Invalid operation; —An operand is invalid for the operation about to be
Math Libraries 239 11 Arithmetic Exceptions An arithmetic exception arises when an attempted atomic arithmetic operationdoes not produce an acceptable result. The meaning of the terms “atomic” and“acceptable” may vary, depending on the context. Following are the five types of IEEE floating-point exc...
Page 264 - Division by zero; Math Library Exception-Handling Function:
240 Pascal 4.0 User’s Guide 11 • Division by zero —The divisor is zero, and the dividend is a finite non-zero number; or, more generally, an exact infinite result is delivered by anoperation on finite operands. • Overflow —The correctly rounded result is larger than the largest number in the require...
Page 265 - If your
Math Libraries 241 11 If your matherr() function returns a non-zero result, no exception message is printed, and errno is not set. DOMAIN Argument domain exception SING Argument singularity OVERFLOW Overflow range exception UNDERFLOW Underflow range exception TLOSS Total loss of significance PLOSS P...
Page 266 - libsunmath
242 Pascal 4.0 User’s Guide 11 libsunmath Support for IEEE Modes and Exceptions ieee_handler() is used primarily to establish a signal handler for a particular floating-point exception or group of exceptions. The syntax of this function is described in the ieee_handler (3M) man page. This following ...
Page 267 - The syntax of this function is described in the
Math Libraries 243 11 The syntax of this function is described in the ieee_flags (3M) man page. If an exception is raised at any time during program execution, then its flag isset, unless it is explicitly cleared. Clearing accrued exceptions is done by a call,as shown in the following Pascal program...
Page 269 - Pascal Preprocessor; Conditional Variables
245 Pascal Preprocessor A This appendix describes the preprocessors, cpp (1) and cppas . cpp cpp (1) is the C language preprocessor. Pascal runs your source program through cpp (1) when you compile it without the –xl option. For a complete description of cpp (1), see the Solaris documentation. cppas...
Page 270 - true; Compiler Directives
246 Pascal 4.0 User’s Guide A A defined conditional variable is enabled ( true ) when it appears in either the %enable directive or in the –config option; otherwise, it is disabled ( false ), as in: The following section describes %var and %enable . Programs that contain conditional variables must b...
Page 271 - Syntax
Pascal Preprocessor 247 A The rest of this appendix contains detailed descriptions and examples of eachdirective. The %config Directive The %config directive is a predefined conditional variable with a value of either true or false . Syntax %config Comments %config is true when you compile your prog...
Page 272 - Example
248 Pascal 4.0 User’s Guide A Example The Pascal program, config.p , which defines the conditional variables one and two program config_example(output); { This program demonstrates the use of the %config compiler directive. } var a: integer := maxint; b: integer := minint; %var one two begin writeln...
Page 276 - Comments
252 Pascal 4.0 User’s Guide A Comments If the expression in %if expression %then is false , pc skips over the %then part and executes the %elseif part instead. expression consists of a conditional variable and the optional boolean operators, and , or , and not . See the %else listing for examples of...
Page 278 - enable
254 Pascal 4.0 User’s Guide A The %enable Directive The %enable directive sets a conditional variable to true . Syntax %enable var1 ..., varN Comments A defined conditional variable is enable ( true ) when it appears in either the %enable directive or in the -config option. Conditional variables are...
Page 280 - string
256 Pascal 4.0 User’s Guide A Syntax %error ' string ' Comments pc does not produce an object file. Example The %exit Directive The %exit directive instructs the compiler to stop processing the current Pascal source file. Syntax %exit The Pascal program, error.p program error_example(output); { This...
Page 281 - xpression
Pascal Preprocessor 257 A Comments If the compiler encounters an %exit directive within an include file, it stops processing the include file, but continues processing the source file in which it is included. In effect, %exit is equivalent to an end-of-file marker. When the compiler processes an %ex...
Page 283 - expression consists of a conditional variable and the optional
Pascal Preprocessor 259 A Comments expression consists of a conditional variable and the optional boolean operators and , or , and not . See the %else listing for examples of expression. %ifdef is especially useful for determining whether or not a conditional variable has been declared in an include...
Page 286 - See the example under “The %list Directive.”
262 Pascal 4.0 User’s Guide A The %nolist Directive The %nolist directive disables the program listing. Syntax %nolist; Comments %nolist is the default. Example See the example under “The %list Directive.” The listing includes the timeeach unit was compiled and thename of each unit compiled. hostnam...
Page 287 - cppas
Pascal Preprocessor 263 A The %slibrary Directive cppas treats %slibrar y in the same manner as the %include directive. See “The %include Directive” on page 259. The %var Directive The %var directive defines conditional variables for the preprocessor. Syntax %var var1 ..., varN Comments A conditiona...
Page 289 - Error Messages; ts
265 Error Messages B The following is a list of the error messages produced by Pascal, arranged bymessage number. 10010: Builtin <function> takes exactly <number> argumen ts 10020: Builtin <function> takes at least <number> arguments 10030: Builtin <function> takes at l...
Page 319 - 6140: Extension to WITH statement not allowed
Error Messages 295 B 26140: Extension to WITH statement not allowed 27010: Integer overflow in constant expression The following are internal error messages. If any of them is displayed, contactSun Customer Support. 18330: NAME with no symbol table entry 18340: ir_symbol: unknown class 18350: ir_lea...
Page 321 - Index
297 Index A –a option to pc command, 24 a.out , 2, 8, 9, 17 address parameters, 169alignment of types in FORTRAN, 165 and operator, 38 AnswerBook, xxiiarguments, See parametersarithmetic exceptions in math libraries, 239 arrays, conformant parameters by value, 101, 114, 123, 193 as (1) assembler, 40...