Sun Microsystems SunSoft Pascal 4.0 User Manual
Sun Microsystems SunSoft Pascal 4.0 User Manual

Sun Microsystems SunSoft Pascal 4.0 User Manual

Hewlett-packard user guide printer printer
Table of Contents

Advertisement

Quick Links

Pascal 4.0 User's Guide
A Sun Microsystems, Inc. Business
2550 Garcia Avenue
Mountain View, CA 94043
U.S.A.
Part No.: 802-2943-10
Revision A, November 1995

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the SunSoft Pascal 4.0 and is the answer not in the manual?

Questions and answers

Summary of Contents for Sun Microsystems SunSoft Pascal 4.0

  • Page 1 Pascal 4.0 User’s Guide A Sun Microsystems, Inc. Business 2550 Garcia Avenue Mountain View, CA 94043 U.S.A. Part No.: 802-2943-10 Revision A, November 1995...
  • Page 2 LOOK is a registered trademark of Novell, Inc. PostScript and Display PostScript are trademarks of Adobe Systems, Inc. ® ® PowerPC™ is a trademark of International Business Machines Corporation. HP and HP-UX are registered trademarks of Hewlett-Packard Company. All other product names mentioned herein are the trademarks of their respective owners.
  • Page 3: Table Of Contents

    Contents Preface........... . 1.
  • Page 4 Pascal 4.0 User’s Guide Compiling the Program ......Running the Program ....... Renaming the Executable File .
  • Page 5 –c ..........-calign .
  • Page 6 Pascal 4.0 User’s Guide –L ..........–l .
  • Page 7 -R path[:dir] ........-Rw.
  • Page 8 viii Pascal 4.0 User’s Guide -xlibmieee ........-xlibmil .
  • Page 9 Sharing Variables Between Units ..... . Libraries ..........5.
  • Page 10 Pascal 4.0 User’s Guide Function Return Values......Parameters That Are Pointers to Procedures ... . Procedures and Functions as Parameters .
  • Page 11 General Parameter-Passing in FORTRAN and Pascal..Procedure Calls: FORTRAN-Pascal ..... . . Variable Parameters....... . . Value Parameters .
  • Page 12 Pascal 4.0 User’s Guide The scalar Class ........Procedure and Function Type Errors.
  • Page 13 An Example ........Sample Translation of an XView Function to Pascal .
  • Page 14 Pascal 4.0 User’s Guide...
  • Page 15 Figures Figure 3-1 Organization of Pascal Compilation..... . Figure 3-2 Options in Program Text ....... Figure 10-1 A Sample Class Hierarchy .
  • Page 16 Pascal 4.0 User’s Guide...
  • Page 17 Tables Table 3-1 File Name Suffixes Recognized by Pascal ....Table 3-2 Options That Can Be Passed in Program Text ... . . Table 3-3 The -xarch Values .
  • Page 18 Table 10-1 Table 11-1 xviii Pascal 4.0 User’s Guide C Declarations to Pascal Declarations ....Contents of Math Libraries......
  • Page 19: Operating Environment

    Operating Environment Installation Preface This manual describes the Pascal 4.0 compiler from SunSoft™. The purpose of this manual is to help you begin writing and compiling Pascal programs on a SPARCstation™. In a previous major release, this Pascal compiler also ran on Solaris 1.x. Some features remain in the documentation as being for Solaris 1.x only.
  • Page 20 Audience This guide was prepared for software engineers who write Pascal programs on a SPARCstation. It assumes you are familiar with ISO standard Pascal and the Solaris™ operating system. Organization This guide contains the following chapters: • • • • •...
  • Page 21: Conventions Used In This Guide

    • This guide concludes with an index. Conventions Used in This Guide This guide contains syntax diagrams of the Pascal language in extended Backus-Naur Formalism (BNF) notation. Here are the meta symbols: Table P-1 BNF Meta Symbols Meta Symbol { a } 'abc' The following table describes the type styles and symbols used in this guide: Table P-2 Typographic Conventions...
  • Page 22: Related Documentation

    Shell Prompts in Command Examples The following table shows the default system prompt and superuser prompt for the C shell, Bourne shell, and Korn shell. Table P-3 Shell Prompts Shell C shell prompt C shell superuser prompt Bourne shell and Korn shell prompt Bourne shell and Korn shell superuser prompt Related Documentation This manual is designed to accompany the following documents:...
  • Page 23: Readme Files

    A floating-point white paper, “What Every Scientist Should Know About Floating-Point Arithmetic,” by David Goldberg, in PostScript™ format. The file is called floating-point.ps, and can be printed on any PostScript- compatible printer that has Palatino font. It can be viewed on-line by using the imagetool command: hostname% imagetool floating-point.ps This paper is also available in the AnswerBook system.
  • Page 24 Table P-4 Documents in Hard Copy and in AnswerBook (Continued) Title Numerical Computation Guide README What Every Scientist Should Know About Floating-Point Arithmetic xxiv Pascal 4.0 User’s Guide Hard Copy On-Line X (AnswerBook) X (CD-ROM) X (AnswerBook and CD-ROM)
  • Page 25: Introduction

    Standards Introduction This chapter gives an overview of the features of Pascal, including compatibility, internationalization, and licensing. It contains the following sections: Standards Pascal Compiler Features Compatibility Text Editors Debuggers XView Toolkit Native Language Support Licensing Pascal is a derivative of the Berkeley Pascal system distributed with UNIX FIPS PUB BSD.
  • Page 26: Pascal Compiler

    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 the following: •...
  • Page 27: Text Editors

    Text Editors The operating system provides two main editors: • • Debuggers SunSoft offers a variety of programming tools that run in the Solaris operating environment. For debugging, the following tools are available: • • You can use Pascal with fix-and-continue, a debugger functionality. See the debugger documentation for details of this feature.
  • Page 28: Internationalization

    Internationalization A product can support up to four levels of internationalization: • • • • Pascal supports all four levels. See the Pascal 4.0 Reference Manual for a description of the date and time functions in internationalized formats. Pascal does not allow input and output in the various international formats. If it does, it does not comply with the Pascal language standard, 770 X3.97-1983.
  • Page 29: Locale

    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, the French decimal unit. Locale You can change your application from one native language to another by setting the locale.
  • Page 30 Pascal 4.0 User’s Guide...
  • Page 31: Pascal Programs

    Pascal Programs This chapter cites two examples that illustrate how to compile and execute a program. It also explains how to use the traceback facility to find out why a program fails. The sections are: Building a program with SPARCompiler Pascal requires three steps: 1.
  • Page 32: Compiling The Program

    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. Pascal 4.0 User’s Guide program temperature(output) ; { Program to convert temperatures from Fahrenheit to Celsius.
  • Page 33: Running The Program

    Running the Program To run the program, enter a.out at the prompt. The output of temp.p is then displayed: hostname% a.out Fahrenheit ---------- 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.
  • Page 34: An Interactive Pascal Program

    Now run the program by typing the name of the executable file. The output follows: 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 equivalent to the standard output file, stdout.
  • Page 35: Compiling The Program

    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 each line you type.
  • Page 36: Using A File Name As A File Variable

    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 the program statement.
  • Page 37: Where Did My Program Fail

    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 utility finds the routine that triggers the error. Using Pascal Traceback Pascal traceback installs signal handlers on selected signals and dumps a backtrace when those signals are caught.
  • Page 38: Using A Sample Program With Segmentation Violation

    Using a Sample Program with Segmentation Violation A segmentation violation occurs when your program tries to reference memory outside your address space. The operating system detects this action and generates an error message. Following is an example program, SegViol.p, which contains a segmentation violation: Compiling and Running the Program When you compile and run the program, you receive output similar to the following.
  • Page 39 hostname% pc SegViol.p hostname% a.out *** a.out terminated by signal 11: segmentation violation *** Traceback being written to a.out.trace Abort (core dumped) hostname% more a.out.trace *** Stacktrace of a.out *** Program terminated due to segmentation violation [3] __PC0__sigdie(0xb, 0xefffedf0, 0xefffec30, 0x0, 0x1, 0x0), at 0x12128 ---- called from signal handler with signal 11 (SIGSEGV) ------ [4] ErrorInHere(), at 0x115ec [5] Call2(0xefffefc8, 0xefffefa8, 0xefffef88, 0x0, 0xef74dd58, 0x0), at 0x11624...
  • Page 40 Try compiling SegViol.p with –g: hostname% pc -g SegViol.p hostname% a.out *** a.out terminated by signal 11: segmentation violation *** Traceback being written to a.out.trace Abort (core dumped) hostname% more a.out.trace *** Stacktrace of a.out *** Program terminated due to segmentation violation [3] __PC0__sigdie(0xb, 0xefffedf0, 0xefffec30, 0x0, 0x1, 0x0), at 0x12128 ---- called from signal handler with signal 11 (SIGSEGV) ------ [4] ErrorInHere(), line 12 in “SegViol.p”...
  • Page 41: The Pascal Compiler

    The Pascal Compiler 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 chapter contains the following sections:...
  • Page 42: Compile And Link Sequence

    To identify the version number given an executable or object file created by the Pascal 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 compiler driver, which calls several programs or passes of the program, each of which processes the program.
  • Page 43: Language Preprocessor

    Figure 3-1 shows the sequence of events when you invoke pc. Compiler Source and preprocessor include files cpp or cppas Figure 3-1 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. If you use the –xl switch, pc calls the alternate preprocessor cppas.
  • Page 44: File Name Extensions Accepted By Pc

    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 extensions. Table 3-1 lists the most important extensions. The table notes that pc can produce assembler source files as well as unlinked object files.
  • Page 45: Option-Passing On The Command-Line

    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 file name. For example, this command activates the listing option -l, which is off by default: hostname% pc -l rmc.p The following command causes the generated object file to be named rmc...
  • Page 46 Table 3-2 1. The options p and t are different when they are used within program text and when they are used on the You set options within comments, which can be delimited by either { and } or (* and *). The first character in the comment must be the $ (dollar sign). $ must be immediately followed by an option letter.
  • Page 47: Options

    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. Program: program options (output); begin {$l+ Turns on listing} writeln ('After $l-'); {$l- Turns off listing} {Notice that this line prints.} writeln ('After $l+');...
  • Page 48: Bbinding

    It is inefficient for Pascal to send each character to a terminal as it generates its output. It is even less efficient if the output is the input of another program, such as the line printer daemon, lpr(1). To gain efficiency, Pascal buffers output characters; it saves the characters in memory until the buffer is full and then outputs the entire buffer in one system interaction.
  • Page 49: Bsdmalloc

    The –b option on the command-line turns on block-buffering with a block size of 1,024. You cannot turn off buffering from the command-line. If you give the –b option in a comment in the program, you can turn off buffering or turn on block buffering. The valid values are: {$b0} {$b1} {$b2}...
  • Page 50: Calign

    –c The –c option instructs the compiler not to call the linker, ld(1). The Pascal compiler, pc, leaves a .o or object file for each source file. Without –c, pc calls the linker when it finishes compilation, and produces an executable file, called a.out by default.
  • Page 51: Config

    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 handles the DOMAIN Apollo See Appendix A, “Pascal Preprocessor,”...
  • Page 52: Dalign

    –dalign The –dalign option instructs the compiler to generate double load and store instructions wherever possible for faster execution. All double-typed data become double-aligned, so do not use this option when correct alignment is not ensured. (Solaris 2.x only) The -dn option specifies static linking in the link editor. -dryrun The –dryrun option instructs the compiler to show, but not execute, the commands constructed by the compilation driver.
  • Page 53: Fnonstd

    Do not use this option for programs that depend on IEEE standard exception handling; you can get different numerical results, premature program termination, or unexpected SIGFPE signals. Note – The criteria for the -fast option vary with the compilers from SunSoft: C, C++, FORTRAN 77, Fortran 90, and Pascal.
  • Page 54: Ftrap=T

    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 2.x only) The -ftrap=t option sets the IEEE 754 trapping mode in effect at startup.
  • Page 55: Hname

    –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 You can compile using both the -g and -O options. However, there are some side effects: •...
  • Page 56: Help Or -Flags

    Every executable file has a list of needed shared library files. When the runtime linker links the library into an executable file, the linker copies the intrinsic name from the library into that list of needed shared library files. If there is no intrinsic name of a shared library, then the linker copies the path of the shared library file instead.
  • Page 57: Ldirectory

    –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 and character constants. The –L option is most useful for transporting programs from other systems.
  • Page 58: Libmieee

    -libmieee Forces IEEE 754 style return values for math routines in exceptional cases. In such 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 and operating system release available on this system.
  • Page 59: Native

    –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 only) The -nocx option makes the output executable file about 128K bytes smaller by not linking with the -lcx option.
  • Page 60: Notrace

    -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 ensures boolean expressions are only evaluated as much as needed to determine the result.
  • Page 61 –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, -xO3 Same as -O3, but traces the effects of pointer assignments and gathers alias information.
  • Page 62: O Filename

    This command causes the optimizer to try to recover if it reaches 16 megabytes of data space. This limit cannot be greater than the machine’s total available swap space, and in practice, should be small enough to permit normal use of the machine while a large compilation is in progress.
  • Page 63: P And -Pg

    –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 periodic sample taken by the system, rather than by line counters. Using the -p Option To generate an execution profile using the –p option: 1.
  • Page 64: Qoption

    –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. The program value can be either as(1) (Solaris 1.x only), fbe(1) (Solaris 2.x only), cpp(1), cppas, inline(1), iropt, ld(1), pc0, or pc3.
  • Page 65: R Path[:Dir]

    (Solaris 1.x only) The –R option instructs pc to call the assembler, as(1). This option merges the data segment of the resulting program with the text segment. See also -xMerge (Solaris 2.x only). -R path[ : dir] (Solaris 2.x only) The -Rpath[:dir] option passes a colon-separated list of directories that specify the library search path used by the runtime linker.
  • Page 66 The compiler issues warnings at the end of the procedure where the record variables 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 are initialized, as the control flow may be different.
  • Page 67 Examples: The Pascal main program, r.p program p; (record and array of records) procedure qq; type compl = record re, im: integer end; var z: compl; begin writeln(z.im); writeln(a[1].re); end; begin end. The commands to compile r.p hostname% pc -Rw r.p and the -Rw warnings that are Fri Jan 27 17:35:50 1995 issued...
  • Page 68 The commands to compile rr.p and the -Rw warnings that are issued The Pascal main program, recvar.p (variant record) The commands to compile recvar.p Pascal 4.0 User’s Guide hostname% pc -Rw rr.p Mon Feb 20 14:59:04 1995 In procedure qq: w 18280 field r1.b is used but never set w 18280 field r1.a is used but never set w 18280 field r2.b is used but never set...
  • Page 69 The Pascal main program, program p; with.p (with statement) type C = record re, im: integer end; procedure qq; begin end; begin end. The commands to compile and hostname% pc -Rw with.p execute with.p Mon Feb 20 16:28:34 1995 with.p: In procedure qq: w 18280 variable c is used but never set w 18260 variable rc is neither used nor set...
  • Page 70: S[Level]

    –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] The –s option instructs the compiler to accept standard Pascal only.
  • Page 71: Temp=Dir

    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 the standard libraries with which it is to be linked, such as libc. The linker allows name conflicts, which may cause erroneous runtime behavior in your program.
  • Page 72: Time

    –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. hostname% pc -time hello.p cpp:time U:0.0s+S:0.1s=0.2s REAL:1.6s 11%. core T:0k D:0k. io IN:4b OUT:3b. pf IN:25p OUt:184p. pc0:time U:0.0s+S:0.3s=0.4s REAL:3.2s 13%.
  • Page 73: U Name

    –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 sets of options that insert checks into the object file, as follows:...
  • Page 74 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 to those of the specified architecture, and allows the specified set of instructions.
  • Page 75: Table 3-3 The -Xarch Values

    v7, v8, and v8a are all binary compatible. v8plus and v8plusa are binary compatible with each other and forward, but not backward. For any particular choice, the generated executable can run much more slowly on earlier architectures (to the left in the above list). Table 3-3 The -xarch Values Value...
  • Page 76 Table 3-3 Value v8plus v8plusa Pascal 4.0 User’s Guide The -xarch Values (Continued) Meaning Limit the instruction set to V8 architecture. This option uses the best instruction set for good performance on the V8 architecture, but without quad-precision floating-point instructions. Example: SPARCstation 10 Limit the instruction set to the V8plus version of the V9 architecture.
  • Page 77: Xcache=C

    -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: • • • • The si/li/ai are defined as follows: Although this option can be used alone, it is part of the expansion of the - target option;...
  • Page 78: Xchip=C

    Example: -xcache=16/32/4:1024/32/1 specifies the following: Level 1 cache has: -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 Although this option can be used alone, it is part of the expansion of the - target option;...
  • Page 79: Xcg89

    Table 3-5 The -xchip Values (Continued) Value Meaning Use timing properties of the MicroSPARC II chip. micro2 Use timing properties of the HyperSPARC™ chip. hyper Use timing properties of the HyperSPARC II chip. hyper2 Use timing properties of the Weitek powerup Use timing properties of the UltraSPARC chip.
  • Page 80: Xildoff

    -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 this default by using the -xildon option.
  • Page 81: Xlibmopt

    -xlibmopt Uses a math routine library optimized for performance. The results may be slightly different than those produced by the normal math library. This option is implied by the -fast option. –xlicinfo The -xlicinfo option returns information about the licensing system. In particular, it returns the name of the license server and the IDs of users who have licenses checked out.
  • Page 82: Xpg

    Generates the highest level of optimization. Uses optimization algorithms that take more compilation time or that do not have as high a certainty of improving execution time. Optimization at this level is more likely to improve performance if it is done with profile feedback. See -xprofile=p. If the optimizer runs out of memory, it tries to recover by retrying the current procedure at a lower level of optimization and resumes subsequent procedures at the original level specified in the command-line option.
  • Page 83: Table 3-6 The -Xprofile Values

    This option causes execution frequency data to be collected and saved during execution, then the data can be used in subsequent runs to improve performance. Table 3-6 The -xprofile Values Value Meaning Collect and save execution frequency for later use by the optimizer. collect The compiler inserts code to measure the execution frequency at a low level.
  • Page 84: Xregs=R

    -xregs=r (Solaris 2.x only) The -xregs= 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 Table 3-7 Value appl no%appl float no%float The default is -xregs=appl,float. Pascal 4.0 User’s Guide option specifies the usage of registers for the The -xregs Values Meaning...
  • Page 85: Xsafe=Mem

    –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. •...
  • Page 86: Xspace

    -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: native, generic, system-name. The -xtarget option permits a quick and easy specification of the -xarch, -xchip, and -xcache combinations that occur on real systems.
  • Page 87: Table 3-9 -Xtarget Expansions

    very important. This is especially true when running on the newer SPARC processors. However, for most programs and older SPARC processors, the performance gain is negligible and a generic specification is sufficient. Each specific value for -xtarget expands into a specific set of values for the - xarch, -xchip, and -xcache options.
  • Page 88 -xtarget sun4/670 sun4/690 sselc ssipc ssipx sslc sslt sslx sslx2 ssslc ss1plus ss2p ssvyger ss10 ss10/hs11 ss10/hs12 ss10/hs14 ss10/20 ss10/hs21 ss10/hs22 ss10/30 ss10/40 ss10/41 ss10/50 Pascal 4.0 User’s Guide -xarch -xchip micro micro micro2 powerup micro2 micro2 micro2 super hyper hyper hyper super...
  • Page 89 -xtarget -xarch ss10/51 ss10/61 ss10/71 ss10/402 ss10/412 ss10/512 ss10/514 ss10/612 ss10/712 ss20/hs11 ss20/hs12 ss20/hs14 ss20/hs21 ss20/hs22 ss20/51 ss20/61 ss20/71 ss20/91 ss20/502 ss10/512 ss20/514 ss20/612 ss20/712 ss20/912 ss600/41 ss600/51 ss600/61 ss600/120 The Pascal Compiler -xchip -xcache super 16/32/4:1024/32/1 super 16/32/4:1024/32/1 super2 16/32/4:1024/32/1 super 16/32/4...
  • Page 90: Ztext

    -xtarget ss600/140 ss600/412 ss600/ ss600/ ss600/ ss1000 sc2000 cs6400 solb5 solb6 ultra ultra1/140 ultra1/170 ultra1/1170 ultra1/2170 ultra1/2200 –Z The –Z option instructs pc to insert code that initializes all local variables to zero. Standard Pascal does not allow initialization of variables. -ztext (Solaris 2.x only) The -ztext option forces a fatal error if relocations remain against non-writable, allocatable sections.
  • Page 91: Program Construction And Management

    Program Construction and Management This chapter is an introduction to the methods generally used to construct and manage programs using Pascal. It describes units and libraries in two separate sections: Units For many reasons, it is often inconvenient to store a program in a single file, as in the case of a very large program.
  • Page 92: Using Program Units And Module Units

    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 among a number of programs.
  • Page 93: Compiling With Units

    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 the procedure. The keyword extern declares that say_hello is declared in a module unit. • Module unit—This unit can begin with an optional module header, followed by a set of compilable declarations and definitions.
  • Page 94: Using Units And Header Files

    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 produces an object file with the extension .o.
  • Page 95: Sharing Variables Between Units

    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 are global across a unit (that is, not declared locally in a routine) can be public or private.
  • Page 96 Here is a program unit that declares a variable: Here is a module unit that declares a variable with the same name: Pascal 4.0 User’s Guide program program_unit3 (output); x : integer; procedure say_hello; external; begin for x := 1 to 5 do say_hello end.
  • Page 97 By default, both definitions of variable x are public. Thus, when you compile and link the program and module units, references to x refer to the same variable, as follows: hostname% pc program_unit3.p module_unit3.p program_unit.p: module_unit.p: Linking: hostname% a.out Hello, world for the 1 time. Hello, world for the 2 time.
  • Page 98: Libraries

    Libraries You can use a module unit as a library of useful functions. The simplest way to do so is to create a source file containing the definitions of your library routines and then compile it using the -c option. You can then link the resulting .o file to any number of files.
  • Page 99: Separate Compilation

    Separate Compilation This chapter describes how to compile Pascal programs in separate units. Chapter 4, “Program Construction and Management,” gives an introduction to the concepts in this chapter. Following are the sections: In separate compilation, a program is divided into several units that can be separately compiled into object (.o) files.
  • Page 100: Using Program Units

    Using Program Units The program unit is the source program with the program header. It has the following syntax: <program unit> ::= <program heading> <declaration list> <program body> Each program you write can have only one program unit. The program body is the first code that Pascal executes.
  • Page 101: Compiling Without The -Xl Option

    Compiling without the There are three ways of sharing variables and routines across units when you compile 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 places, that variable is shared between units.
  • Page 102 The commands to compile and execute shrvar_prog.p and shrvar_mod.p Using extern Option to Share Routines If a program or module calls a procedure not defined in that unit, you must declare 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 in shrvar_prog.p.
  • Page 103 The program unit, inc_prog.p, which includes the file include.h The module unit, inc_mod.p, which also includes the file include.h The include file, include.h The commands to compile and execute inc_prog.p and inc_mod.p Separate Compilation program inc_prog; #include "include.h" begin { program body} global := 1;...
  • Page 104: Using The -Xl Option

    Using the 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 “Sharing Public Variables” on page 77.
  • Page 105 The program unit, pubvar_prog.p, which declares global as public The module unit, pubvar_mod.p, which also declares global as public The commands to compile and execute pubvar_prog.p and pubvar_mod.p Separate Compilation program pubvar_prog; public var global: integer; procedure proc; external; begin global := 1;...
  • Page 106 Using the This example makes global public using the define attribute of the variable declaration. The program unit, defvar_prog.p The module unit, defvar_mod.p, which makes global public using the define attribute Pascal 4.0 User’s Guide Variable Attribute define program defvar_prog; global: extern integer;...
  • Page 107 The commands to compile and execute defvar_prog.p and defvar_mod.p Using the 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.
  • Page 108 The module unit, defvar_mod2.p, which defines global in a define declaration The commands to compile and execute defvar_prog.p and defvar_mod2.p Using 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.
  • Page 109 The program unit inc_prog2.p The module unit inc_mod2.p The include file, include2.h Separate Compilation program inc_prog2; %include "include2.h"; procedure proc; extern; begin global := 1; writeln('From MAIN, before PROC: ',global); proc; writeln('From MAIN, after PROC: ',global); end. { proc } module inc_mod2;...
  • Page 110 The commands to compile and execute inc_prog2.p and inc_mod2.p 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 defines the procedure.
  • Page 111: Sharing Declarations In Multiple Units

    The module unit, ext_mod.p The include file, extern.h The commands to compile and execute ext_prog.p and ext_mod.p Sharing Declarations in Multiple Units Using extern and external directives for procedure and function declarations, you can optionally specify the source language of a separately compiled procedure or function.
  • Page 112 For routines declared extern fortran or external fortran, the changes in the calling sequence are as follows: • • • For routines declared extern c or external c, a warning is generated if you attempt to pass a nested function. When you compile your program with the –xl option, you can also use nonpascal to declare non-Pascal routines when porting written in...
  • Page 113: The C-Pascal Interface

    The C–Pascal Interface 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: •...
  • Page 114: Compatibility Of Types For C And Pascal

    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 use any special options, but the -calign option is again useful. The C object library, libc, is automatically brought in for every Pascal compilation.
  • Page 115: Table 6-2 C And Pascal Size And Alignment Of Compatible Types With -Xl

    Table 6-1 C and Pascal Size and Alignment of Compatible Types (Continued) Pascal Type array variant record fields in packed record Table 6-2 C and Pascal Size and Alignment of Compatible Types with –xl Pascal Type real integer Precautions with Compatible Types This section describes the precautions you should take when working with compatible types.
  • Page 116: Incompatibilities

    Array Indexes Pascal array indexes can start at any integer; C array indexes always start at zero. Aggregate Types Aggregate types include arrays, varying arrays, sets, strings, alphas, records, and variant records. Pascal aggregate types may require alignment and layout adjustment to match C unions, structures, and arrays.
  • Page 117: General Parameter Passing In C And Pascal

    Pascal Set Types In Pascal, a set type is implemented as a bit vector, which is similar to a C short-word array, where each short-word contains two bytes. Thus, sets are bit-vectors, and they are allocated in multiples of 16 bits. To find out the size of a set, enter the following code: Direct access to individual elements of a set is highly machine-dependent and should be avoided.
  • Page 118: Variable Parameters

    The C main program, SampMain.c. Note the procedure definition and call. The commands to compile and execute Samp.p and SampMain.c Variable Parameters Pascal passes all variable parameters by reference, which C can do, too. Pascal 4.0 User’s Guide #include <stdio.h> extern void Samp(int *, double *);...
  • Page 119 Simple Types without –xl Without -xl, simple types match, as in the following example: The Pascal procedure, procedure SimVar( SimVar.p begin end; { SimVar } The C main program, #include <stdio.h> SimVarMain.c extern void SimVar(char *, char *, char *, short *, int main(void) The C–Pascal Interface var t, f: boolean;...
  • Page 120 The commands to compile and execute SimVar.p and SimVarMain.c 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;...
  • Page 121 The C main program, #include <stdio.h> StrVarMain.c #include <string.h> struct TVarLenStr { extern void StrVar(char *, char *, struct TVarLenStr *); int main(void) The commands to compile and hostname% pc -c StrVar.p execute StrVar.p and hostname% cc StrVar.o StrVarMain.c -lpc StrVarMain.c hostname% a.out Fixed Arrays...
  • Page 122 The Pascal procedure, FixVec.p The C main program, FixVecMain.c The commands to compile and execute FixVec.p and FixVecMain.c Although it does not apply in this example, arrays of aggregates in Pascal have, by default, a size that is always a multiple of four bytes. When you use the -calign option to compile the Pascal code, that difference with C is eliminated.
  • Page 123 The Pascal procedure, DaysOfWeek.p end; The C main program, DaysOfWeekMain.c The commands to compile and hostname% pc -c DaysOfWeek.p execute DaysOfWeek.p and hostname% cc DaysOfWeek.o DaysOfWeekMain.c -lpc DaysOfWeekMain.c without hostname% a.out -calign The commands to compile and hostname% pc -c -calign DaysOfWeek.p execute DaysOfWeek.p and hostname% cc DaysOfWeek.o DaysOfWeekMain.c -lpc DaysOfWeekMain.c with...
  • Page 124 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 size checking for separate compilations. However, if you want to use an existing Pascal procedure that has a univ array, you can do so.
  • Page 125 The commands to compile and hostname% pc -c -calign UniVec.p execute UniVec.p and hostname% cc UniVec.o UniVecMain.c -lpc UniVecMain.c with -calign hostname% a.out Conformant Arrays For single-dimension conformant arrays, pass upper and lower bounds, placed after the declared parameter list. If the array is multidimensional, pass element widths as well, one element width for each dimension, except the last one.
  • Page 126 Examples of single-dimension, multidimension, and array-of-character conformant arrays follow. Conformant arrays are included here only because they are a relatively standard feature; there are usually more efficient and simpler ways to do the same thing. Example 1: Single-Dimension Array The Pascal procedure, IntCA.p.
  • Page 127 Example 2: Multi-Dimension Array The Pascal procedure, procedure RealCA(var A: array [r1..r2: integer] of RealCA.p. Pascal passes low bound, high bound, and element width. begin end; { RealCA } The C main program, RealCAMain.c. Array M has 2 rows of 3 columns each. c1 and c2 are the first and last columns.
  • Page 128 The commands to compile and execute RealCA.p and RealCAMain.c with -calign 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 elements in the next larger element multiplied by wc. width of next largest element = (ub - lb + 1) * wc In general, (lb, ub, wc) are the bounds and element width of the next lower dimension of the array.
  • Page 129 The commands to compile and hostname% pc -c -calign ChrCAVar.p execute ChrCAVar.p and hostname% cc ChrCAVar.o ChrCAVarMain.c -lpc ChrCAVarMain.c hostname% a.out This is a string Records and Structures In most cases, a Pascal record describes the same objects as its C structure equivalent, provided that the components have compatible types and are declared in the same order.
  • Page 130 The C main program, StruChrMain.c The commands to compile and execute StruChr.p and StruChrMain.c The record in the example above has, by default, the same size and alignment as the equivalent C record. Some records, though, are laid out differently unless you use the -calign option.
  • Page 131 Consider this example: The Pascal routine, type DayWeather.p procedure DayWeather(var W: TDayWeatherArray; begin end; The C main program, #include <stdio.h> DayWeatherMain.c #include <string.h> struct TDayRec { extern void DayWeather(struct TDayRec [], int *); int main(void) The C–Pascal Interface TDayWeather = record TDay: array [0..8] of char;...
  • Page 132 When you compile the Pascal routine without using the -calign option, the program does not work correctly. The commands to compile and execute DayWeather.p and DayWeatherMain.c without -calign The commands to compile and execute DayWeather.p and DayWeatherMain.c with -calign Variant Records C equivalents of variant records can sometimes be constructed, although there is some variation with architecture and sometimes a need to adjust alignment.
  • Page 133 The C main program, #include <stdio.h> VarRecMain.c extern void VarRec(struct vlr *); int main(void) The commands to compile and hostname% pc -c -calign VarRec.p execute VarRec.p and hostname% cc VarRec.o VarRecMain.c -lpc VarRecMain.c hostname% a.out The C–Pascal Interface struct vlr { char tag;...
  • Page 134: Table 6-3 Set Implementation

    Pascal Set Type In Pascal, a set type is implemented as a bit vector, which is similar to a C short-word array. Direct access to individual elements of a set is highly machine-dependent and should be avoided. In Pascal, bits are numbered within a byte from the most significant to least, as shown in Table 6-3.
  • Page 135 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, procedure IntSetVar(var s: intset); IntSetVar.p, which has an begin intset of the elements [1, 3, 7, 8] end;...
  • Page 136: Value Parameters

    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. Pascal 4.0 User’s Guide procedure SimVal( t, f: boolean;...
  • Page 137 The C main program, #include <stdio.h> SimValMain.c extern void SimVal( int main(void) The commands to compile and hostname% pc -c SimVal.p execute SimVal.p and hostname% cc SimVal.o SimValMain.c -lpc SimValMain.c hostname% a.out If no function prototype is provided for SimVal in SimValMain.c, then sr:shortreal must be changed to sr:real in SimVal.p.
  • Page 138 Arrays Since C cannot pass arrays by value, it cannot pass strings of characters, fixed arrays, or univ arrays by value. Conformant Arrays Pascal passes all value parameters on the stack or in registers, except for value conformant array parameters, which are handled by creating a copy in the caller environment and passing a pointer to the copy.
  • Page 139: Function Return Values

    The commands to compile and hostname% pc -c -calign ChrCAVal.p execute ChrCAVal.p and hostname% cc ChrCAVal.o ChrCAValMain.c -lpc ChrCAValMain.c with hostname% a.out -calign This is a string Function Return Values Function return values match types the same as with parameters, and they pass in much the same way.
  • Page 140: Input And Output

    The commands to compile and execute RetReal.p and RetRealMain.c Input and Output If your C main program calls a Pascal procedure that does I/O, then include the 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 Pascal procedure, IO.p...
  • Page 141: Procedure Calls: Pascal-C

    The commands to compile and execute IO.p and IOMain.c 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 pass in a straightforward manner, as follows: The C function, SimRef.c...
  • Page 142 The Pascal main program, SimRefMain.p The commands to compile and execute SimRef.c and SimRefMain.p Strings of Characters The alfa and string types pass simply; varying strings are more complicated. All pass by reference. Pascal 4.0 User’s Guide program SimRefMain(output); t, f: boolean; c: char;...
  • Page 143 The C function, StrVar.c #include <string.h> struct TVarLenStr { void StrVar(char *s10, char *s80, struct TVarLenStr *vls) The Pascal main program, program StrVarMain(output); StrVarMain.p type procedure StrVar(var a: alfa; var s: string; var v: TVarStr); begin end. The C–Pascal Interface int nbytes;...
  • Page 144 The commands to compile and execute StrVar.c and StrVarMain.p Avoid constructs that rely on strings being in static variable storage. For example, you could use mktemp(3) in Pascal as follows: Incorrect use of string in static variable storage This use is incorrect, since mktemp()modifies its argument. Instead, use the C library routine strncpy() (see string(3)) to copy the string constant to a declared char array variable, as in: Correct solution using the C...
  • Page 145 Fixed Arrays For a fixed-array parameter, pass the same type and size, as in this example: The C function, FixVec.c The Pascal main program, program FixVecMain(output); FixVecMain.p type procedure FixVec(var XV: TVec; var XSum: integer); external c; begin end. { FixVecMain } The commands to compile and hostname% cc -c FixVec.c execute FixVec.c and...
  • Page 146 The univ Arrays The univ arrays that are in, out, in out, or var parameters pass by reference. Here is an example: The C function, UniVec.c The Pascal main program, UniVecMain.p The commands to compile and execute UniVec.c and UniVecMain.p Pascal 4.0 User’s Guide void UniVec(int V[3], int Last, int *Sum) int i;...
  • Page 147 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 placed after the declared parameter list. If the array is multidimensional, pass element widths as well, one element width for each dimension, except the last one.
  • Page 148 The commands to compile and execute IntCA.c and IntCAMain.p The -calign option is not needed for this example, but may be necessary if the array parameter is an array of aggregates. Records and Structures In most cases, a Pascal record describes the same objects as its C structure equivalent, provided that the components have compatible types and are declared in the same order.
  • Page 149 The Pascal main program, program StruChrMain(output); StruChrMain.p type procedure StruChr(var vls: TVarLenStr); external c; begin end. { StruChrMain } The commands to compile and hostname% cc -c StruChr.c execute StruChr.c and hostname% pc -calign StruChr.o StruChrMain.p StruChrMain.p hostname% a.out Variant Records C equivalents of variant records can sometimes be constructed, although there is some variation with the architecture, and sometimes you have to adjust the alignment.
  • Page 150 Following are some examples: The C function, VarRec.c Pascal 4.0 User’s Guide 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_part.a_var.ch2 = 'Z';...
  • Page 151 The Pascal main program, program VarRecMain; VarRecMain.p type procedure VarRec(var d: vr); external c; begin end. { VarRecMain } The commands to compile and hostname% cc -c VarRec.c execute VarRec.c and hostname% pc -calign VarRec.o VarRecMain.p VarRecMain.p hostname% a.out The -calign option is not needed in the previous example, but may be necessary if the record contains aggregates.
  • Page 152 See this example: The C function, NonPas.c. In the function for_C, s is a pointer (declared var in the procedure declaration), and len is not a pointer (not declared var in the procedure declaration). In the function for_nonpascal, s is still a pointer (though not declared var in the procedure declaration), and len is now a...
  • Page 153: Value Parameters

    Value Parameters In general, Pascal passes value parameters in registers or on the stack, widening to a full word if necessary. Simple Types With value parameters, simple types match, as in the following example: The C function, SimVal.c void SimVal( The C–Pascal Interface char char...
  • Page 154: Function Return Values

    The Pascal main program, SimValMain.p The commands to compile and execute SimVal.c and SimValMain.p Function Return Values Function return values match types in the same manner as with parameters, and they pass in much the same way. See “Variable Parameters” on page 94. The following example shows how to pass simple types.
  • Page 155: Parameters That Are Pointers To Procedures

    The C function, RetReal.c double RetReal(double *x) The Pascal main program, program RetRealMain; RetRealMain.p function RetReal(var x: real): real; external c; begin end. { RetRealMain } The commands to compile and hostname% cc -c RetReal.c execute RetReal.c and hostname% pc RetReal.o RetRealMain.p RetRealMain.p hostname% a.out Parameters That Are Pointers to Procedures...
  • Page 156: Procedures And Functions As Parameters

    The Pascal main program, ProcParMain.p, which calls the C procedure, proc_c, passing it the address of the Pascal procedure, proc_pas. The C procedure assigns a value to the string s, and calls the procedure whose pointer it just received. Then the Pascal procedure, proc_pas, writes a literal constant and the string it just received.
  • Page 157: Global Variables In C And Pascal

    functions can be passed to other languages as arguments, the static links for all procedure or function arguments are placed after the end of the conformant array bounds pairs, if any. Routines in other languages can be passed to Pascal; a dummy argument must be passed in the position normally occupied by the passed routine’s static link.
  • Page 158: File-Passing Between Pascal And C

    The commands to compile and execute GloVar.p and GloVarMain.c without –xl. With -xl, the Pascal integer must be paired with a C short int and declared public since the default visibility is private. File-Passing Between Pascal and C The C procedure, UseFilePtr.c The Pascal main program, UseFilePtrMain.p...
  • Page 159 The commands to compile and hostname% cc -c UseFilePtr.c execute UseFilePtc.c and hostname% pc UseFilePtr.o UseFilePtrMain.p UseFilePtrMain.p hostname% a.out hostname% cat myfile.data [1] Passing the file descriptor [2] and writing information [3] to a file The C–Pascal Interface...
  • Page 160 Pascal 4.0 User’s Guide...
  • Page 161: The C++-Pascal Interface

    The C++–Pascal Interface This chapter describes how to mix C++ and Pascal modules in the same program. 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.
  • Page 162: Compatibility Of Types For C++ And Pascal

    Compatibility of Types for C++ and Pascal Table 6-1 and Table 6-2 on page 90 list the default sizes and alignments of compatible 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 normally appends type information to the function names.
  • Page 163: Arguments Passed By Reference

    The C++ main program, #include <stdio.h> SampMain.cc extern "C" void Samp (int&, double&); int main(void) The commands to compile and hostname% pc -c Samp.p execute Samp.p and hostname% CC Samp.o SampMain.cc -lpc SampMain.cc hostname% a.out 7 3.14 Arguments Passed by Reference C++ arguments can be passed by reference.
  • Page 164 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 Pascal 4.0 User’s Guide procedure SamRef ( var t, f: boolean; var c: char; var i: integer;...
  • Page 165 The C++ main program, #include <stdio.h> SamRefMain.cc extern "C" void SamRef ( int main(void) SamRef (t, f, c, i, s, r, d); The commands to compile and hostname% pc -c SamRef.p execute SamRef.p and SamRefMain.cc Simple Types with the -xl Option With the -xl option, the Pascal real must be paired with a C++ float;...
  • Page 166 Strings of Characters The C++ counterpart to the Pascal alfa and string types are arrays. The C++ counterpart to the Pascal varying type is a structure. Here is an example: The Pascal procedure, StrRef.p Pascal 4.0 User’s Guide type TVarStr = varying [25] of char; procedure StrRef ( var a: alfa;...
  • Page 167 The C++ main program, #include <stdio.h> StrRefMain.cc extern "C" void StrRef ( int main(void) The commands to compile and hostname% pc -c StrRef.p execute StrRef.p and StrRefMain.cc The C++–Pascal Interface #include <string.h> struct TVarLenStr { int NBytes; char a[25]; char char TVarLenStr &);...
  • Page 168 Fixed Arrays The Pascal procedure, FixVec.p The C++ main program, FixVedMain.cc The commands to compile and execute FixVec.p and FixVecMain.cc Pascal 4.0 User’s Guide type TVec = array [0..8] of integer; procedure FixVec ( var V: TVec; var Sum: integer i: integer;...
  • Page 169 Although it does not apply to this example, arrays of aggregates in Pascal have, by default, a size that is a multiple of four bytes. When you use the -calign option to compile Pascal code, that difference from C++ is eliminated.
  • Page 170 The commands to compile and execute DaysOfWeek.p and DaysOfWeekMain.cc without the -calign option The commands to compile and execute DaysOfWeek.p and DaysOfWeekMain.cc with the -calign option Records and Structures A Pascal record of an integer and a character string matches a C++ structure of the same constructs, as in this example: The Pascal procedure, StruChr.p.
  • Page 171 The C++ main program, #include <stdio.h> StruChrMain.cc extern "C" void StruChr ( int main(void) The commands to compile and hostname% pc -c StruChr.p execute StruChr.p and StruChr.cc The C++–Pascal Interface #include <string.h> struct TVarLenStr { int NBytes; char a[25]; TVarLenStr &); struct TVarLenStr vls;...
  • Page 172 Consider this example: The Pascal procedure, DayWeather.p Pascal 4.0 User’s Guide 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 begin W[1].TDay := 'Sunday';...
  • Page 173 The C++ main program, #include <stdio.h> DayWeatherMain.cc extern "C" void DayWeather ( int main(void) The C++–Pascal Interface #include <string.h> struct TDayRec { char TDay[9]; char TWeather[21]; TDayRec [2], int &); struct TDayRec dr[2]; int NBytes; char s25[25]; char t25[25]; NBytes = 0; DayWeather (dr, NBytes);...
  • Page 174: Arguments Passed By Value

    When you compile the Pascal routine without the -calign option, the program does not work correctly. Compile with the -calign option. The program now works correctly. Arguments Passed by Value C++ arguments can be passed by value. In this section, we describe how they work with Pascal.
  • Page 175 Simple Types without the -xl Option Without the -xl option, simple types match, as in the following example: The Pascal procedure, procedure SimVal( SimVal.p begin end; The C++–Pascal Interface t, f: boolean; c: char; si:integer16; i: integer; sr:shortreal; r: real; var Reply: integer);...
  • Page 176: Function Return Values

    The C++ main program, SimValMain.cc The commands to compile and execute SimVal.p and SimVal.cc Function Return Values Function return values match types in the same manner as with parameters. They pass in much the same way. Pascal 4.0 User’s Guide #include <stdio.h>...
  • Page 177 Simple Types Simple types pass in a straightforward way, as in the following example: The Pascal function, function RetReal (r: real): real; RetReal.p begin The C++ main program, #include <stdio.h> RetRealMain.cc extern "C" double RetReal (double); int main(void) The commands to compile and hostname% pc -c RetReal.p execute RetReal.p and RetRealMain.cc...
  • Page 178 Type shortreal The Pascal function, RetShortReal.p The C++ main program, RetShortRealMain.cc The commands to compile and execute RetShortReal.p and RetRealMain.cc Input and Output The Pascal function, IO.p Pascal 4.0 User’s Guide function RetShortReal (r: shortreal): shortreal; begin RetShortReal := r + 1.0 end;...
  • Page 179: Procedure Calls: Pascal-C

    The C++ main program, IOMain.cc The commands to compile and execute IO.p and IOMain.cc Procedure Calls: Pascal–C++ A Pascal main program can also call C++ functions. The following examples show you how to pass simple types and arguments and include the commands that are used to compile and execute the final programs.
  • Page 180 Simple Types Passed by Reference Simple types pass in a straightforward manner, as follows: The C++ function, SimRef.cc Pascal 4.0 User’s Guide extern "C" void SimRef ( char &t, char &f, char &c, &i, short &s, float &r, double &d) t = 1;...
  • Page 181: Arguments Passed By Value

    The Pascal main program, program SimRefMain (output); SimRefMain.p procedure SimRef ( begin The commands to compile and hostname% CC -c SimRef.cc execute SimRef.cc and hostname% pc SimRef.o SimRefMain.p SimRefMain.p hostname% a.out true false z 9 9 9.9 9.9 Arguments Passed by Value Pascal arguments can also be passed by value.
  • Page 182 Simple Types Simple types match with value parameters. See the following example: The C++ function, SimVal.cc Pascal 4.0 User’s Guide extern "C" void SimVal( char char char short float double r, int& Reply) Reply = 0; if (t) Reply += if (! f) Reply += if (c == 'z')
  • Page 183: Function Return Values

    The Pascal main program, program SimValMain(output); SimValMain.p procedure SimVal( begin end. The commands to compile and hostname% CC -c SimVal.cc execute SimVal.cc and hostname% pc SimVal.o SimValMain.p SimValMain.p hostname% a.out args = 111111 Function Return Values Function return values match types in the same manner as with parameters. They pass in much the same way.
  • Page 184 The following example shows how to pass simple types: The C++ function, RetReal.cc The Pascal main program, RetRealMain.p The commands to compile and execute RetReal.cc and RetRealMain.p Pascal 4.0 User’s Guide extern "C" double RetReal (double &x) return (x + 1.0); program RetRealMain (output);...
  • Page 185: Global Variables In C++ And Pascal

    Global Variables in C++ and Pascal If the types are compatible, a global variable can be shared between C++ and Pascal. See this example: The Pascal procedure, GloVar.p The C++ main program, GloVarMain.cc The commands to compile and execute GloVar.p and GloVarMain.cc The C++–Pascal Interface Year: integer;...
  • Page 186: Pascal File Pointers To C

    Pascal File Pointers to C++ You can pass a file pointer from Pascal to C++, then have C++ do the I/O. See this example. The C++ procedure, UseFilePtr.cc The C++ main program, UseFilePtrMain.p The commands to compile and execute UseFilePtr.cc and UseFilePtrMain.p Pascal 4.0 User’s Guide #include <stdio.h>...
  • Page 187: The Fortran-Pascal Interface

    The FORTRAN–Pascal Interface This chapter describes how to mix FORTRAN 77 and Pascal modules in the same 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 module.
  • Page 188: Compatibility Of Types For Fortran And Pascal

    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 use the compiler options –lpfc and –lF77. The –lF77 option links the FORTRAN object library, libf77.
  • Page 189: Precautions With Compatible Types

    Table 8-1 Default Sizes and Alignments of Compatible Types (Pascal and FORTRAN) Pascal Type double longreal real single shortreal integer16 integer32 integer -128..127 boolean alfa char string varying[n] of char array record Table 8-2 lists the default sizes and alignments of compatible types for FORTRAN and Pascal with the -xl option: Table 8-2 Sizes and Alignments of Compatible Types (Pascal and FORTRAN) with –xl...
  • Page 190: Incompatibilities

    Character Strings There are some precautions to take with character strings regarding the null byte, passing by value, and static storage: • • • • Array Indexes The Pascal and FORTRAN array indexes can start at any integer; be sure they match.
  • Page 191: Multidimensional Arrays

    Pascal Set Types In Pascal, a set type is implemented as a bit vector, which is similar to a FORTRAN 16-bit word. Direct access to individual elements of a set is highly machine-dependent and should be avoided. Multidimensional Arrays Pascal multidimension arrays are incompatible with FORTRAN multi- dimension arrays.
  • Page 192: Procedure Calls: Fortran-Pascal

    Procedure Calls: FORTRAN-Pascal Here are examples of how a FORTRAN main program calls a Pascal procedure. The Pascal procedure, Samp.p. Note the procedure definition. The procedure name in the procedure statement is in lowercase with a trailing underscore (_). This format is required to match the conventions of the FORTRAN compiler.
  • Page 193 See the following example: The Pascal procedure, procedure simvar_(var t, f: boolean; var c: char; SimVar.p begin end; { simvar_ } The FORTRAN main program, SimVarmain.f The commands to compile and hostname% pc -c SimVar.p execute SimVar.p and hostname% f77 SimVar.o SimVarmain.f -lpfc -lpc SimVarmain.f SimVarmain.f: hostname% a.out...
  • Page 194 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 Pascal alfa and string types is a character string, and the FORTRAN counterpart to the Pascal varying is a...
  • Page 195 The commands to compile and hostname% pc -c StrVar.p execute StrVar.p and hostname% f77 StrVar.o StrVarmain.f -lpfc -lpc StrVarmain.f StrVarmain.f: hostname% a.out s10='abcdefghij' s80='abcdefghijklmnopqrtstuvwxyz s25='oyvay' Fixed Arrays For a fixed array parameter, pass the same type and size by reference, as shown in the following example: The Pascal procedure, type...
  • Page 196 The commands to compile and execute FixVec.p and FixVecmain.f The univ Arrays You can pass any size array to a Pascal procedure expecting a univ array, but there is no advantage in doing so, since there is no type or size checking for separate compilations.
  • Page 197 The commands to compile and hostname% execute UniVec.p and hostname% f77 UniVec.o UniVecmain.f -lpfc -lpc UniVecmain.f UniVecmain.f: hostname% a.out Conformant Arrays For conformant arrays, with single-dimension array, pass upper and lower bounds, placed after the declared parameter list, as in: Pascal passes the bounds by value, so FORTRAN must pass them by value, too.
  • Page 198 Example 1: Single-Dimension Array The Pascal procedure, IntCA.p. Pascal passes the bounds by value. The FORTRAN main program, IntCAmain.f The commands to compile and execute IntCA.p and IntCAmain.f Example 2: Array of Characters The Pascal procedure, ChrCA.p. Pascal passes the bounds by value.
  • Page 199 The FORTRAN main program, ChrCAmain.f The commands to compile and hostname% pc -c ChrCA.p execute ChrCA.p and hostname% f77 ChrCA.o ChrCAmain.f -lpfc -lpc CharCAmain.f ChrCAmain.f: hostname% a.out This is a string Records and Structures In most cases, a Pascal record describes the same objects as its FORTRAN structure equivalent, provided that the components have compatible types and are declared in the same order.
  • Page 200 A Pascal record of an integer and a character string matches a FORTRAN structure of the same. Consider these examples: The Pascal procedure, StruChr.p The FORTRAN main program, StruChrmain.f The commands to compile and execute Struchr.p and StruChrmain.f Pascal 4.0 User’s Guide type lenstr = record...
  • Page 201 Variant Records FORTRAN equivalents of variant records can sometimes be constructed, although there is some variation with architecture, and sometimes you need to adjust the alignment. The Pascal procedure, type vr = record VarRec.p procedure varrec_ ( var Rec: vr ) ; begin end;...
  • Page 202 The FORTRAN main program, VarRecmain.f. The variable ALIGN is integer*2, and is needed to match the Pascal variant record layout. The commands to compile and execute VarRec.p and VarRecmain.f without –xl Pascal 4.0 User’s Guide structure /a_var/ character ch1, ch2 end structure structure /b_var/ character flag...
  • Page 203 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, procedure intsetvar_(var s: intset);...
  • Page 204: Value Parameters

    The commands to compile and execute IntSetVar.p and IntSetVarmain.f. The output of this example depends on the architecture of your machine. Value Parameters In general, Pascal passes value parameters on the stack. Simple Types without the –xl Option Without the -xl option, simple types match. Pascal 4.0 User’s Guide hostname% pc -c IntSetVar.p hostname% f77 IntSetVar.o IntSetVarmain.f -lpfc -lpc...
  • Page 205 See the following example: The Pascal procedure, procedure simval_(t, f: boolean; c: char; i: integer; SimVal.p. t, f, c, i, r, and s are value parameters. begin end; { simval_ } The FORTRAN main program, SimValmain.f & & The FORTRAN–Pascal Interface r: real;...
  • Page 206 The commands to compile and execute SimVal.p and SimValmain.f Simple Types with the –xl Option With the -xl option, match Pascal real with FORTRAN real and Pascal integer with FORTRAN integer*2. You can pass by value using the %VAL() feature of FORTRAN. Type shortreal Unlike C, there is no problem with passing shortreal value parameters between Pascal and FORTRAN.
  • Page 207: Pointers

    Pascal procedure, ChrCAx.p procedure chrca_ ( a: array [lb..ub:integer] of char) ; begin end; { chrca_ } The FORTRAN main program, ChrCAmain.f The commands to compile and hostname% pc -c ChrCAx.p execute ChrCAx.p and hostname% f77 ChrCAx.o ChrCAmain.f -lpfc -lpc ChrCAmain.f ChrCAmain.f: hostname% a.out...
  • Page 208: Function Return Values

    The FORTRAN main program, PassPtrmain.f. In the FORTRAN main program, the name is converted to lowercase. Uppsercase is ignored. The commands to compile and execute PastPtr.p and PassPtrmain.f Function Return Values Function return values match types the same as with parameters, and they pass in much the same way.
  • Page 209: Procedure Calls: Pascal-Fortran

    Simple Types The simple types pass in a straightforward way, as follows: The Pascal function, RetReal.p The FORTRAN main program, RetRealmain.f The commands to compile and execute RetReal.p and RetRealmain.f without –xl Type shortreal There is no problem with returning a shortreal function value between Pascal and FORTRAN.
  • Page 210: Variable Parameters

    Variable Parameters Pascal passes all var parameters by reference, the FORTRAN default. Simple Types Simple types pass in a straightforward manner, as follows: The FORTRAN subroutine, SimVar.f Pascal 4.0 User’s Guide subroutine SimVar ( t, f, c, i, d, si, sr ) logical*1 t, f character...
  • Page 211 The Pascal main program, program SimVarmain(output); SimVarmain.p procedure simvar(var t, f: boolean; var c: char; begin end. { SimVarmain } The commands to compile and execute SimVar.p and SimVarmain.p Strings of Characters The alfa and string types pass simply; varying strings are a little tricky. All pass by reference.
  • Page 212 The FORTRAN subroutine, StrVar.f The Pascal main program, StrVarmain.p Pascal 4.0 User’s Guide subroutine StrVar ( s10, s80, vls ) character s10*10, s80*80 structure /VarLenStr/ integer nbytes character a*25 end structure record /VarLenStr/ vls character ax*10, sx*80, vx*5 data ax / "abcdefghij"...
  • Page 213 The commands to compile and hostname% f77 -c StrVar.f execute StrVar.f and StrVar.f: StrVarmain.p hostname% pc StrVar.o StrVarmain.p -lpfc -lF77 hostname% a.out abcdefghij abcdefghijklmnopqrstuvwxyz oyvay length(v)= 5 Character Dummy Arguments When you call FORTRAN 77 routines with character dummy arguments from Pascal programs—that is, routines in which string arguments are specified as character*(*) in the FORTRAN source, there is no explicit analogue in Pascal.
  • Page 214 The following example illustrates this method: The Pascal program, sun.pas program Test(input,output); procedure mygrout_(var prompt :string; length :integer32); external; begin end. The FORTRAN subroutine, mygrout.f The commands to compile and run this program Pascal 4.0 User’s Guide s : string; writeln('Starting...');...
  • Page 215 Fixed Arrays For a fixed-array parameter, pass the same type and size by reference: The FORTRAN subroutine, FixVec.f The Pascal main program, program FixVecmain(output); FixVecmain.p type procedure fixvec(var XV: VecTyp; var XSum: integer); begin end. { FixVecmain } The commands to compile and execute FixVec.f and FixVecmain.p The FORTRAN–Pascal Interface...
  • Page 216 The univ Arrays The univ arrays that are in, out, in out, or var parameters pass by reference. The FORTRAN subroutine, UniVec.f The Pascal main program, UniVecmain.p Pascal 4.0 User’s Guide subroutine UniVec ( V, Last, Sum ) integer V(0:2), Last, Sum, i Sum = 0 do i = 0, Last Sum = Sum + V(i)
  • Page 217 The commands to compile and execute UniVec.f and UniVecmain.p Conformant Arrays Pascal-conformant array parameters are not compatible if Pascal calls FORTRAN. The FORTRAN–Pascal Interface hostname% f77 -c UniVec.f UniVec.f: univec: hostname% pc UniVec.o UniVecmain.p -lpfc -lF77 hostname% a.out...
  • Page 218 Records and Structures Records and structures pass as follows: The FORTRAN subroutine, StruChr.f The Pascal main program, StruChrmain.p Pascal 4.0 User’s Guide subroutine StruChr ( vls ) structure /VarLenStr/ integer nbytes character a*25 end structure record /VarLenStr/ vls vls.a(1:5) = 'oyvay' vls.nbytes = 5 return program StruChrmain;...
  • Page 219 The commands to compile and execute StruChr.f and StruChrmain.p Variant Records You can construct FORTRAN equivalents of variant records. There is some variation with architecture, and sometimes you need to adjust the alignment. The FORTRAN–Pascal Interface hostname% f77 -c StruChr.f StruChr.f: struchr: hostname% pc StruChr.o StruChrmain.p -lpfc -lF77...
  • Page 220 Chapter 6, “The C–Pascal Interface,” has an example that matches the following example. The FORTRAN subroutine, VarRec.f. The variable ALIGN is integer*2 and is needed to match the Pascal variant record layout. Pascal 4.0 User’s Guide subroutine VarRec ( VRec ) structure /a_var/ character ch1, ch2 end structure...
  • Page 221: Value Parameters

    The Pascal main program, program VarRecmain; VarRecmain.p type procedure varrec(var d: vr); external fortran; begin end. { VarRecmain } The commands to compile and execute VarRec.f and VarRecmain.p without –xl Value Parameters With external fortran on the procedure statement, Pascal passes value parameters as FORTRAN expects them.
  • Page 222 Simple Types With external fortran, the procedure name in the procedure statement and in the call must be in lowercase, with no underscore (_). The FORTRAN subroutine, SimVal.f Pascal 4.0 User’s Guide subroutine SimVal( t, f, c, i, d, s, reply ) logical*1 t, f character...
  • Page 223 The Pascal main program, SimValmain.p The commands to compile and execute SimVal.f and SimValmain.p The FORTRAN–Pascal Interface program SimVal(output); t: boolean := true; f: boolean := false; c: char := 'z'; i: integer := 9; r: real := 9.9; s: integer16 := 9; args: integer;...
  • Page 224: Pointers

    Pointers Pointers are easy to pass, as shown in the following example: The FORTRAN subroutine, PassPtr.f. In the FORTRAN subroutine, the name is converted to lowercase. Uppsercase is ignored. The Pascal main program, PassPtrmain.p. In the Pascal program, where it calls the FORTRAN subroutine, the name must be in lowercase.
  • Page 225: Function Return Values

    The commands to compile and execute PassPtr.f and PassPtrmain.p Function Return Values Function return values match types the same as with parameters, and they pass in much the same way. Simple Types The simple types pass in a straightforward way, as in this example: The FORTRAN function, double precision function retreal ( x ) RetReal.f...
  • Page 226: Routines As Parameters

    The commands to compile and execute RetReal.f and RetRealmain.p 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 procedure, write it as follows: The FORTRAN subroutine,...
  • Page 227 The Pascal main program, program PassProcmain; PassProcmain.p procedure passproc(var u: real; var v: real; procedure AddOne(var x: real; var y: real); begin end; { AddOne } begin end. { PassProcmain } The commands to compile and execute PassProc.f and PassProcmain.p If the procedure is not a top-level procedure, then you do not deal with how to pass it, because that requires allowing for the static link.
  • Page 228 Routines in other languages can be passed to Pascal; a dummy argument must be passed in the position normally occupied by the static link of the passed routine. If the passed routine is not a Pascal routine, the argument is used only as a placeholder.
  • Page 229: Error Diagnostics

    Error Diagnostics This chapter discusses the errors you may come across while writing software programs 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 common syntax errors in Pascal programs and the ways that the compiler handles them.
  • Page 230: String Errors

    Most nonprinting characters in your input are also illegal, except in character constants and character strings. Except for the tab and formfeed characters, which are used to format the program, nonprinting characters in the input file print as the character ? in your listing. String Errors Encountering an end-of-line after an opening string quotation mark (') without first encountering the matching closing quote yields the diagnostic:...
  • Page 231: Replacements, Insertions, And Deletions

    Replacements, Insertions, and Deletions When Pascal encounters a syntax error in the input text, the compiler invokes an error recovery procedure. This procedure examines the input text immediately after the point of error and uses a set of simple corrections to determine whether or not to allow the analysis to continue.
  • Page 232: Undefined Or Improper Identifiers

    Undefined or Improper Identifiers If an identifier is encountered in the input but is undeclared, the error recovery mechanism replaces it with an identifier of the appropriate class. Further references to this identifier are summarized at the end of the containing procedure, function, or at the end of the program.
  • Page 233: Expected And Unexpected End-Of-File

    These are the error messages hostname% pc synerr2.p you receive when you compile Mon Feb 13 11:02:04 1995 synerr2.p: synerr2.p. On line 6, parentheses are used for e 18480-------^--- subscripting (as in FORTRAN), E 18490-----------------^--- rather than the square brackets that are used in Pascal.
  • Page 234: Compiler Semantic Errors

    When you compile mism.p, the end-of-file is reached before an end delimiter Compiler Semantic Errors The following sections explain the typical formats and terminology used in Pascal error messages. Format of the Error Diagnostics In the example program above, the error diagnostics from the Pascal compiler include the line number in the text of the program, as well as the text of the error message.
  • Page 235: The Scalar Class

    Thus, if you try to assign an integer value to a char variable, you receive a diagnostic as follows: Mon Feb 13 13:16:20 1995 inchar.p: E 25190 line 6 - Type clash: integer is incompatible with char ... 25560: Type of expression clashed with type of variable in assignment In this case, one error produces a two-line error message.
  • Page 236: Scalar Error Messages

    Scalar Error Messages Error messages stating that scalar (user-defined) types cannot be read from and written 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 strings red, green, and blue in any way.
  • Page 237 program expr_example(output); begin end. { expr_example } This program generates the following error messages: hostname% pc expr.p Mon Feb 13 13:36:51 1995 expr.p: E 13050 line 16 - Constant string too long E 20070 line 17 - Left operand of and must be Boolean, not set E 25550 line 18 - expression has invalid type E 20030 line 18 -...
  • Page 238: Type Equivalence

    Type Equivalence The Pascal compiler produces several diagnostics that generate the following message: non-equivalent types In general, Pascal considers types to be the same only if they derive from the same type identifier. Therefore, the following two variables have different types, even though the types look the same and have the same characteristics.
  • Page 239: Unreachable Statements

    To make the assignment statement work, you must declare a type and use it to declare the variables, as follows: Alternatively, you could use the declaration: The assignment statement then works. Unreachable Statements Pascal flags unreachable statements. Such statements usually correspond to errors in the program logic, as shown in the following example: The Pascal program, program unreached_example(output);...
  • Page 240: The Goto Statement

    This error message is generated when you compile unreached.p. A statement is considered to be reachable if there is a potential path of control, even if it cannot be taken. Thus, no diagnostic is produced for the statement: The goto Statement Pascal detects and produces an error message about goto statements that transfer control into structured statements—for example, for and while.
  • Page 241: Compiler Panics, I/O Errors

    If you declare a label but never use it, Pascal gives you a warning. This is true even for a label declared in global scope. Compiler Panics, I/O Errors One class of error that rarely occurs, but which causes termination of all processing when it does, is a panic.
  • Page 242 <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 <filename>...
  • Page 243 Argument to argv of <number> is out of range Assertion #<number> failed: <assertion message> Cannot close null file Cannot compute cos(<number>) Cannot compute sin(<number>) Cannot open null file Enumerated type value of <number> is out of range on output Floating point division by zero Floating point operand is signaling Not-A-Number Floating point overflow Floating point underflow...
  • Page 244 Pointer value (<number>) out of legal range Ran out of memory Range lower bound of <number> out of set bounds Range upper bound of <number> out of set bounds Reference to an inactive file Second operand to MOD (<number>) must be greater than zero Statement count limit of <number>...
  • Page 245: The Xview Toolkit

    Overview The XView Toolkit This chapter introduces the XView programmer’s toolkit, a part of the XView application programmer’s interface (API). It assumes you are familiar with XView windows as a user, and introduces XView from a programmer’s point of view. For details, see the XView Programming Manual by Dan Heller, O’Reilly &...
  • Page 246: Tools

    Tools This kit is a collection of functions. The runtime system is based on each application having access to a server-based Notifier, which distributes input to the appropriate window, and a Window Manager, which manages overlapping windows. There is also a Selection Service for exchanging data between windows (in the same or different processes).
  • Page 247: Pascal Interface

    with the root being the class from which all others are descended. In the XView toolkit, the root is the class Generic Object, which has no data fields and no methods. Each descendant of Generic Object is specialized in some way, perhaps with additional data fields or methods.
  • Page 248: Compiling With Libraries

    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 Header Files The header files define the necessary data types, constants, and external procedures necessary to write programs using the XView interface with Pascal.
  • Page 249: Attribute Lists

    Instead of these routines, the Pascal interface to XView defines a separate routine 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 which the attribute is being set.
  • Page 250: Handles

    Example calls are: Here, mymenu is an object of type XV_object. The lists for Attr_avlist are created by functions that have the following names: • • • • Handles When you create an XView object, xv_create() returns a handle for that object.
  • Page 251: Coding Fragment

    Coding Fragment Here is an example that illustrates the style of programming with the XView interface in Pascal. This program: • • • In this example: • • • • Conversion of C to Pascal Here is an example of a problem that you may encounter when converting C to Pascal.
  • Page 252 The Straightforward Part—You can use the following items of information as you find them in the manual, with no change: • • • The More Complex Parts—You must make the following changes: • • • Table 10-1 shows you how to convert C declarations to Pascal. Table 10-1 C Declarations to Pascal Declarations 1.
  • Page 253: Sample Translation Of An Xview Function To Pascal

    Sample Translation of an XView Function to Pascal In the section, “Summary of Procedures and Macros,” in the XView Programming Manual, is the following entry: texsw_insert() Inserts characters in buf into textsw at the current insertion point. inserted is returned. there was a memory allocation failure.
  • Page 254: Sample Program

    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 XView libraries on your system. hostname% pc -Ilocal_library_path xview.p -L$OPENWINHOME/lib \ -lpxview -lxview -lolgx -lX11 Now run the executable file: hostname% a.out...
  • Page 255: Menu Demo Program

    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. The XView Toolkit program MenuDemo(output); #include "stddefs_p.h" #include "attrgetset_p.h" base_frame : Frame;...
  • Page 256 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 Pascal 4.0 User’s Guide base_frame := xv_create(nil, FRAME, 0); set_FRAME_LABEL(base_frame, frame_label); set_FRAME_SHOW_FOOTER(base_frame, TRUE);...
  • Page 257: Math Libraries

    Math Libraries This chapter describes how to use the libm and libsunmath functions in Pascal programs. The math libraries are always accessible from a Pascal program because the Pascal compiler driver pc calls ld, the linker and loader, with the -lsunmath -lm options. If you compile Pascal program with the -v option, it prints the command-line used to call each of the compilation passes.
  • Page 258: Contents Of The Math Libraries

    Contents of the Math Libraries Altogether, there are three math libraries: • • • Table 11-1 lists the contents of the math libraries. Table 11-1 Contents of Math Libraries Algebraic functions Transcendental functions Integral rounding functions Pascal 4.0 User’s Guide 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...
  • Page 259: Libm Functions

    Table 11-1 Contents of Math Libraries (Continued) Random number generators IEEE support functions Error handling function Data conversion BSD miscellaneous Base conversion routines (in libc) FORTRAN intrinsic functions Legend libm Functions Most numerical functions are available in double- and single-precision version. In general, the names of the single-precision version are formed by adding f to the names of the double-precision version.
  • Page 260: Ieee Support Functions

    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(). Pascal 4.0 User’s Guide program TestLibm(output); #include <math_p.h> d0,d1,d2: double; f0,f1,f2: single; begin d0 := 0.0;...
  • Page 261: Ieee_Functions()

    ieee_functions() The functions described in ieee_functions(3M) provide capabilities either required by the IEEE standard or recommended in its appendix. Example: program TestIEEEFunctions(output); #include "math_p.h" d1: double := 1.0; d2: double := 2.0; i1: integer := 1; begin writeln('IEEE functions'); writeln(ilogb(d1)); writeln(isnan(d1));...
  • Page 262: Ieee_Retrospective()

    ieee_retrospective() The libm function ieee_retrospective() prints to stderr information about unrequited exceptions and nonstandard IEEE modes. Pascal programs call ieee_retrospective() on exit by default. SPARC Libraries The libm and libsunmath libraries also contain: • • • There are two facilities for generating uniform pseudo-random numbers, addrans(3M) and lcrans(3M).
  • Page 263: Arithmetic Exceptions

    Arithmetic Exceptions An arithmetic exception arises when an attempted atomic arithmetic operation does 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 exceptions: •...
  • Page 264: Math Library Exception-Handling Function: Matherr()

    • • • • Math Library Exception-Handling Function: matherr() Some libm functions are specified to call matherr()when an exception is detected. You can redefine matherr() by including a function named matherr() in the program. When an exception occurs, a pointer to the exception structure, exc, is passed to the user-supplied matherr() function.
  • Page 265 Argument domain exception DOMAIN Argument singularity SING Overflow range exception OVERFLOW Underflow range exception UNDERFLOW Total loss of significance TLOSS Partial loss of significance PLOSS If your matherr() function returns a non-zero result, no exception message is printed, and errno is not set. program TestMatherr(output);...
  • Page 266: Libsunmath Support For Ieee Modes And Exceptions

    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 Pascal program demonstrates how to abort on division by zero. ieee_flags() is the recommended interface to: •...
  • Page 267 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 is set, unless it is explicitly cleared. Clearing accrued exceptions is done by a call, as shown in the following Pascal program.
  • Page 268 Pascal 4.0 User’s Guide...
  • Page 269 Pascal Preprocessor This appendix describes the preprocessors, cpp(1) and cppas. 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 The cppas preprocessor handles the Pascal conditional variables and compiler directives.
  • Page 270: Compiler Directives

    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 be compiled with the –xl option. Compiler Directives A directive indicates some action for the compiler to take.
  • Page 271 Table A-1 cppas Compiler Directives (Continued) Compiler Directive Stops processing the current Pascal source file. %exit When the compiler encounters a %if expression %then directive, it evaluates expression. If expression is true, pc executes the statements after %then. If expression is false, pc skips over %then. Determines whether or not you previously defined a conditional %ifdef variable in a %var directive.
  • Page 272 Example The Pascal program, config.p, which defines the conditional variables one and The output when you compile config.p without the -config option The output when you define the variable one Pascal 4.0 User’s Guide program config_example(output); { This program demonstrates the use of the %config compiler directive.
  • Page 273 The output when you define two The output when you define foo The %debug Directive The %debug directive instructs pc to compile this line of code when you use the –cond compiler directive. Syntax %debug; Comments The %debug directive works in conjunction with the –cond compiler option. –cond causes pc to compile the lines in your program that begin with %debug.
  • Page 274 Example The Pascal program, debug.p The output when you compile debug.p without the –cond option The output when you use –cond The %else Directive The %else directive provides an alternative action to the %if directive. Syntax %if expression %then %else %endif Pascal 4.0 User’s Guide program debug_example(output);...
  • Page 275 Example The Pascal program, if_then_else.p The output when you compile hostname% pc -xl if_then_else.p if_then_else.p without the hostname% a.out -config It is not red. The output when you supply -config with the argument The %elseif Directive The %elseif directive provides an alternative action to the %if directive. Syntax %if expression %then %elseif expression %then...
  • Page 276 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 expression. Example The Pascal program, elseif.p...
  • Page 277 Syntax %ifdef expression %then %elseifdef expression %then %endif Comments If the expression in %ifdef expression %then is false, pc skips over the %then part and executes the %elseifdef part instead. expression consists of a conditional variable and the optional boolean operators, and, or, and not. See the %else listing for examples of expression.
  • Page 278 The include file, bird.h The output when you enable bird1 with the -config option The output when you enable bird2 with the -config option 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.
  • Page 279 Example The Pascal program, program enable_example(output); enable.p. This example sets the conditional variable two to { This program demonstrates the use of true, which is equivalent to setting the -config option to two on the command-line. %var one, two %enable two begin end.
  • Page 280 Syntax %error Comments pc does not produce an object file. Example The Pascal program, error.p error.p produces this error if you compile it without the –config sparc option. The %exit Directive The %exit directive instructs the compiler to stop processing the current Pascal source file.
  • Page 281 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 %exit directive within an %if or %ifdef construct, it closes all %if or %ifdefs before it stops processing the current file.
  • Page 282 Comments When pc encounters a %if directive, it evaluates expression. If expression is true, pc executes the statements in the %then part. If expression is false, pc skips over the %then part and executes the %else, %elseif, or %endif directive. If no such directive exists, pc proceeds to the next statement. The expression consists of a conditional variable and the optional boolean operators and, or, and not.
  • Page 283 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 file. Example See the example in “The %elseifdef Directive.”...
  • Page 284 The module unit, include_mod.p The include file, include.h The commands to compile and execute ext_prog.p and ext_mod.p The %list Directive The %list directive enables a listing of the program. Syntax %list; Pascal 4.0 User’s Guide module include_mod; define global, proc; %include 'extern.h';...
  • Page 285 Comments The %list directive and the -l compiler option perform the same function. Example The Pascal program, list.p The include file, types.h type Pascal Preprocessor program list_example(output); { This program demonstrates the use of the %list and %nolist directives. } %list;...
  • Page 286 The listing includes the time each unit was compiled and the name of each unit compiled. 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.” Pascal 4.0 User’s Guide hostname% pc -xl list.p Tue Feb 28 15:48 1995...
  • Page 287 The %slibrary Directive cppas treats %slibrary 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 conditional variable is defined when it appears in a %var directive; otherwise, it is undefined.
  • Page 288 Example The Pascal program, warning.p The output when you compile warning.p without the –config option Pascal 4.0 User’s Guide program warning_example(output); { This program demonstrates the use of the %warning compiler directives. } %var blue begin %if blue %then writeln('The color is blue.'); %else %warning 'Color not defined' %endif...
  • Page 289: Error Messages

    Error Messages The following is a list of the error messages produced by Pascal, arranged by message number. 10010: Builtin <function> takes exactly <number> arguments 10020: Builtin <function> takes at least <number> arguments 10030: Builtin <function> takes at least <number> arguments and at most <number>...
  • Page 290 10120: Too many arguments to <function> 10130: Actual argument cannot be conformant array 10140: Actual argument is incompatible with formal var parameter <identifier> of <function> 10150: Actual argument is incompatible with formal <paramtype> parameter <identifier> of <function> 10160: Actual argument to NONPASCAL procedure cannot be conformant array 10170: Extra arguments to ADDR ignored 10180: Argument to <function>...
  • Page 291 10290: Fourth argument to <function> must be of type <type>, not <type> 10300: First argument to <function> cannot be a univ_ptr 10310: <number> argument to <function> must be of type <type>, not <type> 10320: <number> argument to <function> must be unpacked 10330: <number>...
  • Page 292 10470: ord's argument must be of scalar type, not <type> 10480: <function>'s argument must be of scalar type, not <type> 10490: odd's argument must be an integer, not <type> 10500: chr's argument must be an integer, not <type> 10510: Argument to eoln must be a text file, not <type> 10520: Argument to eof must be file, not <type>...
  • Page 293 10660: Second and successive arguments to <function> must be constants 10670: Argument to <function> must be a alfa, not <type> 10680: halt takes no arguments 10690: stlimit requires one argument 10700: stlimit's argument must be an integer, not <type> 10710: remove expects one argument 10720: remove's argument must be a string, not <type>...
  • Page 294 10840: Illegal argument with format radix specification; probably a comma missing 11010: have incompatible conformant array schemas 11020: sizeof(conformant array) is undefined 11030: Conformant arrays are not allowed at ANSI Level 0 11040: Subscripting allowed only on arrays, not on <type>s 11050: subrange value or array subscript (<integer>) is out of range 11060: compiler takes size of array...
  • Page 295 11170: For-statement variable <identifier> cannot be an element of a record 11180: . allowed only on records, not on <type>s 11190: <identifier> is not a field in this record 11200: Record required when specifying variant tags 11210: Missing case constants in variant record 11220: <identifier>...
  • Page 296 12060: Width expressions allowed only in writeln/write calls 12070: Cannot write <type>s with two write widths 12080: Can't write <identifier>s with oct/hex 12090: First write width must be integer, not <type> 12100: Second write width must be integer, not <type> 12110: Negative widths are not allowed 12120: Cannot write unpacked array to textfile 12130: Can't read <type>s from a text file...
  • Page 297 13070: constant argument expected 13080: newline in string or char constant 13090: empty character constant 13100: too many characters in character constant 14010: Constant declarations should precede type, var and routine declarations 14020: Label declarations should precede const, type, var and routine declarations 14030: Type declarations should precede var and routine declarations...
  • Page 298 14140: PUBLIC ignored, procedure was declared INTERNAL or PRIVATE previously 14150: PRIVATE ignored, procedure was declared PUBLIC or as EXTERNAL previously 14160: For-statement variable <identifier> must be declared in the block in which it is used 14170: All labels should be declared in one label part 14180: Expected identifier VARYING in declaration 14190: Variable declarations should precede routine declarations...
  • Page 299 14300: Expected keyword begin after declarations, before statements 14310: Improper initialization for variable <identifier> 14320: <identifier> is already defined globally 14330: Definition of name <identifier> after applied use in <identifier> 14340: Definition of name <identifier> after applied use 14350: <identifier> is already defined in this block 14360: Range lower bound exceeds upper bound 14370: '*' subrange descriptor used in illegal context 14380: Cannot initialize dynamic local variables...
  • Page 300 15100: Cannot open #include file <filename> 15110: line <number> does not exist in file <identifier> 15120: End-of-file expected - QUIT 15130: Unexpected end-of-file - QUIT 16010: <identifier> is not a function 16020: Too many levels of function/procedure nesting 16030: No assignment to the function variable 16040: Functions should not return <type>s 16050: Procedure/function nesting too deep 16060: pcc_fvar(): no result for this function...
  • Page 301 16160: Procedure/function nesting too deep 16170: Can't call <identifier>, its not a pointer to a procedure or function 16180: Can't call <identifier>, it's <class> not a procedure 16190: Procedure <identifier> found where expression required 16200: Illegal procedure call, expecting value 16210: Non-pascal routine <identifier>...
  • Page 302 17100: Predecessor of <integer> is out of range 17110: Value of <integer> is out of range 17120: Range upper bound of <integer> out of set bounds 17130: Range lower bound of <integer> out of set bounds 17140: Value of <integer> out of set bounds 17150: value of <integer>...
  • Page 303 18120: 8 or 9 in octal number 18130: Number too large for this implementation 18140: <operation> is undefined for reals 18150: <identifier> cannot have more elements in z (<integer>) than in a (<integer>) 18160: <identifier> is an unimplemented extension 18180: Initializer must be a string 18190: Initialization string <string>...
  • Page 304 18420: Undefined <identifier> 18430: Undefined identifier 18440: Improper <identifier> identifier 18450: Deleted <token> 18460: Replaced <token> with a <token> 18470: Replaced <class> id with a <class> id 18480: Inserted <token> 18490: Expected <token> 18500: Label <identifier> not defined in correct block 18510: Label <identifier>...
  • Page 305 18630: Unreachable statement 18640: Unrecoverable syntax error - QUIT 18650: Too many syntax errors - QUIT 18660: Input line too long - QUIT 18670: Unrecognizable # statement 18680: Include syntax error - expected ' or \" not found 18690: Absurdly deep include nesting - QUIT 18700: Too many levels of include nesting - QUIT 18710: Bad arbitrary base integer 18720: Bad base <number>...
  • Page 306 19030: Missing program statement 19040: Input is used but not defined in the program statement 19050: Output is used but not defined in the program statement 19060: Program parameter <identifier> is repeated 20010: Left operand of <operator> must be integer, real or set, not <type>...
  • Page 307 20140: Operands of <operator> must both be sets 20150: Set types of operands of <operator> must be compatible 20160: Incorrect statement usage const. with operand 20170: ^ allowed only on files and pointers, not on <type>s 20180: <operation> is an illegal operation on strings 20190: not must operate on a Boolean or Integer, not <type>...
  • Page 308 21070: Conformant array parameters in the same specification must be the same type 21080: actual parameter is not an array 21090: array index type is incompatible with conformant array parameter <identifier> 21100: array index type is not within of index type of conformant array parameter <identifier>...
  • Page 309 21230: Program parameter <identifier> is repeated 21240: Previous declaration for formal parameter '<identifier>' has different type 21250: Previous declaration for formal parameter '<identifier>' has different name '<identifier>' 21260: Previous declaration for procedure '<identifier>' had different number of formal parameters 21270: Formal <class> <name> cannot be qualified 21280: <class>...
  • Page 310 22020: Ran out of memory (case) 22030: Ran out of memory (hash) 22040: Ran out of memory (TRIM) 22050: Ran out of memory (defnl) 22060: Ran out of memory (buffer_ir_pass) 22070: Ran out of memory (string) 22080: Ran out of memory (tralloc) 22090: out of memory (tstr) 22100: out of memory 22110: Ran out of hash tables...
  • Page 311 23070: Routine Options are not standard 23080: External procedures and functions are not standard 23090: Separately compiled routine segments are not standard 23100: UNIV parameters are non-standard 23110: IN parameters are non-standard 23120: OUT parameters are non-standard 23130: IN OUT parameters are non-standard 23140: <identifier>...
  • Page 312 23270: Storage Class non-standard 23280: Initialization in declaration part is non-standard 23290: UNIV_PTR types are non-standard 23300: '_' in an identifier is nonstandard 23310: Octal constants are non-standard 23320: <operator> is non-standard 24010: Cannot exit -- not within a loop 24020: For-statement variable <identifier>...
  • Page 313 24120: Case selectors cannot be <type>s 24130: Duplicate otherwise clause in case statement 24140: Case label type clashed with case selector expression type 24150: Multiply defined label in case, lines <number> and <number> 24160: No case-list-elements 24170: Bad case constant 24180: Range in case label must be in ascending order 24190: Maximum number of case selectors exceeded 24200: Cannot next -- not within a loop...
  • Page 314 24300: Improper use of the DEFINE statement 24310: End matched <keyword> on line <number> 24320: Inserted keyword end matching {begin|record|class} on line <number> 25010: {pack|unpack}: elements of a and z must have the same type 25020: component types of formal and actual arrays are not conformable 25030: Type of function <name>...
  • Page 315 25150: Type clash: packed and unpacked set 25160: Type clash: files not allowed in this context 25170: Type clash: non-identical <class> types 25180: Type clash: <type>s with file components not allowed in this context 25190: Type clash: <type> is incompatible with <type> 25200: Type clash: string and unpacked array 25210: Type clash: string and packed array with lower bound <>...
  • Page 316 25320: Function type should be given only in forward declaration 25330: Different type declared previously for function return <name> 25340: Function type must be specified 25350: Type of expression in while statement must be Boolean, not <type> 25360: Until expression type must be Boolean, not <type>, in repeat statement 25370: Array index type incompatible with declared index type...
  • Page 317 25490: <class> types must be identical in comparisons - operator was <operator> 25500: Index type clashed with set component type for 'in' 25510: Operands of + are of incompatible types 25520: Type names (e.g. <type>) allowed only in declarations 25530: Type name (e.g. <type>) found in illegal context 25540: Set types of operands of <operator>...
  • Page 318 25670: Index type for arrays cannot be real 25680: Array index type is a <type>, not a range or scalar as required 25690: Packed conformant array schema requires type identifier as element type 25700: Illegal type in VARYING array, only type CHAR allowed 25710: Size of <type>...
  • Page 319 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, contact Sun Customer Support. 18330: NAME with no symbol table entry 18340: ir_symbol: unknown class 18350: ir_leaf: cannot take address of op <identifier>...
  • Page 320 Pascal 4.0 User’s Guide...
  • Page 321 Index –a option to pc command, 24 a.out, 2, 8, 9, 17 address parameters, 169 alignment of types in FORTRAN, 165 and operator, 38 AnswerBook, xxii arguments, See parameters arithmetic exceptions in math libraries, 239 arrays, conformant parameters by value, 101, 114, 123, as(1) assembler, 40, 57 assert statement, 25 attributes for XView, 224...
  • Page 322 C++ programming language, 137 to 162 -calign option to pc command, 26 cg, the code generator, 18 –cg89 option to pc command, 26 –cg92 option to pc command, 26 character data type, 33, 46 characters, illegal, 205 compatible types compiler, 8, 11, 17 to 66 compiler directives, 246 to 263 Pascal 4.0 User’s Guide var parameters, 94, 117...
  • Page 323 –config option, 245, 252, 256 defined, 246 undefined, 245 %config directive, 247 –config option to pc command, 27, 246, conformant arrays parameters between Pascal and C, 101, 114, 123 parameters between Pascal and C++, 152, 158, 159 parameters between Pascal and FORTRAN, 182, 193 conventions, xxi #include directive, 67...
  • Page 324 exception-handling function in math executable file, 2, 9, 11, 18, 46 execution profile, 39 %exit directive, 256 expression diagnostics, 212 extended language features, 56 extern external option, See extern option –fast option to pc command, 28 faster linking and initializing, 61 fbe(1) assembler, 40 features, Pascal compiler, 2 file...
  • Page 325 identifier errors, 208 identifiers, 33, 46, 76 IEEE support functions in math libraries, 236 %if directive, 247, 257 %ifdef directive, 255, 257, 258 illegal characters, 205 #include directive, 67 %include directive, 259, 263 include file, 84, 257 and library header files, 74 as header file, 70 introduction, 67 producing a listing of, 32...
  • Page 326 memory, out of, 217 –misalign option to pc command, 34 module –mt option to pc command, 34 mv command, 9 –native option to pc command, 35 -nocx option to pc command, 35 –nolib option to pc command, 35 –nolibmil option to pc command, 35 %nolist directive, 262 nonstandard floating point, 29 -noqueue licensing option, 5, 35...
  • Page 327 –dalign option, 28 –dn option, 28 –dryrun option, 28 –dy option, 28 –fast option, 28 -flags option, 32 –fnonstd option, 29 -fns option, 29 -fround=r option, 29 -ftrap=t option, 30 -G option, 30 –G option, 30 –g option, 31 –H option, 31, 49 –help option, 32 –hname option, 31 –I option, 32...
  • Page 328 procedure program programming public variable, 73, 80 –Qoption to pc command, 40 -qp option to pc command, 40 –Qpath option to pc command, 40 –Qproduce option to pc command, 40 queuing for a license, 5 QUIT errors, 209 -R option to pc command, 41 range check on pointers, 31 reading and writing scalars, errors in, 212 real numbers, errors, 206...
  • Page 329 #define, 27 assert, 25 stdin, 10 stdout, 10 string errors, 206 symbol errors, 208 table for dbx, 61 syntax errors and recovery, 205 to 207 -tc option to pc command, 47 tcov(1) utility, 24 –temp option to pc command, 47 text editor textedit, 3 vi, 3...
  • Page 330 writing a Pascal program, 7 writing scalars, errors in, 212 –xarch=a option to pc command, 49 –xcache=a option to pc command, 53 –xchip=c option to pc command, 54 –xF option to pc command, 55 –xildoff option to pc command, 56 –xildon option to pc command, 56 –xl option to pc command, 56, 245 –xlibmopt option to pc command, 57...
  • Page 331 Index...
  • Page 332 Novell, Inc. PostScript et Display PostScript sont des marques d’Adobe Systems, Inc. PowerPC™ est une marque deposée de ® ® International Business Machines Corporation. HP and HP-UX sont des marques enregistrées par Hewlett-Packard Company. Toutes les marques SPARC sont des marques deposées ou enregitrées de SPARC International, Inc. aux Etats-Unis et dans d’autres pays.

Table of Contents