 |
» |
|
|
 |
|  |  |
If you plan to run your programs only on HP computers,
the effort to port your programs between HP computers is minimal
and the extra features that HP Pascal/HP-UX provides
will make your programming much easier.
However, if you plan to port your programs to another vendor's computer,
the effort to do so will be proportional
to your use of nonstandard HP Pascal/HP-UX extensions.
Even if the system you are porting to has extensions,
it is doubtful that the extensions on that system
have the same form as extensions on HP Pascal/HP-UX.
To determine which features are nonstandard
in an HP Pascal/HP-UX source file,
include the $ANSI ON$ compiler option
at the start of your source file
or use the -A command-line option.
When you compile the source file using the -L command-line option,
the compiler generates a listing file that shows where
nonstandard features are used.
Combined, the ANSI compiler option and the -L command-line option
assure you that you are using only ANSI Standard Pascal features
or that you are aware of where you are using nonstandard features.
Porting Between Series 300/400 and Series 700/800 |  |
This section summarizes some of the HP Pascal/HP-UX language features,
both standard and nonstandard,
that may cause problems when porting Pascal programs
between Series 300/400 and Series 700/800 as well as to or from other systems.
Data Type Sizes and Alignments
Table 1-6 “HP Pascal/HP-UX Data Types” shows the sizes and alignments of the Pascal data
types on HP-UX architectures.
Packing significantly affects data type alignments and sizes.
For more specific information,
refer to HP Pascal/HP-UX Reference Manual; and HP
Pascal/HP-UX Programmer's Guide.
On the Series 300/400,
if the +A command-line option is specified, any data types
larger than two bytes are aligned on a 2-byte boundary.
Table 1-6 HP Pascal/HP-UX Data Types \Type | Size\(bytes)
| Alignment\(300/400) | Alignment\(700/800)
|
|---|
bit16 | 2 | Not supported | 2
| bit32 | 4 | Not supported | 4
| bit52 | 8 | Not supported | 4
| boolean | 1 | 1-byte | 1-byte
| char | 1 | 1-byte | 1-byte
| enumeration
| 2[1] | 2-byte
| 1-, 2-, or 4-byte, based on declared range
| subrange of enumeration
| 2[1]
| same as host enumeration type
| 2-byte or 4-byte, based on declared range
| $extnaddr$ pointer | 8 | Not supported | 4
| integer | 4 | 4-byte | 4-byte
| subrange of integer
≥ -32768 AND ≤ 32767
| 2[1]
| 2-byte | 2-byte
| subrange of integer
< -32768 OR > 32767 | 4 | 4-byte | 4-byte
| longint | 8 | Not supported | 4-byte
| longreal | 8 | 4-byte | 8-byte
| pointer | 4 | 4-byte | 4-byte
| real | 4 | 4-byte | 4-byte
| set | Varies | Varies | Varies
| shortint | 2 | Not supported | 2-byte
|
The TRY/RECOVER construct is supported on all HP-UX implementations.
Escape codes for errors differ significantly between the implementations.
The mark and release procedures are supported
on all HP-UX implementations.
There are minor differences in behavior but code is essentially portable.
Series 300/400 and 700/800 differ in the way each allows association
with an HP-UX file descriptor in the reset procedure.
The association is not similar in the associate procedure.
Series 700/800 uses an option string parameter
on reset, rewrite, open, and append procedures.
Series 300/400 ignores this parameter.
On the Series 700/800, if stdout is a terminal, the output is unbuffered.
If stdout is a file, the output is line-buffered.
Series 300/400 requires the declaration of stderr
after declaring it as a program parameter;
Series 700/800 does not.
Series 700/800 implements the fnum function;
Series 300/400 does not.
Series 300/400 and 700/800 differ in how each handles
eof, get, and put with direct access files.
The close procedure has different default behavior on each system.
Modules are supported on all HP-UX implementations
but some syntactic and semantic differences exist.
For example,
Series 700/800 requires that CONST, TYPE, and VAR declarations
precede routine declarations within the EXPORT section,
whereas Series 300/400 permits them to be intermixed.
Series 300/400 permits separate compilation only within modules.
Series 700/800 can compile outside modules
by using the SUBPROGRAM, GLOBAL, and EXTERNAL compiler options.
Assignment to Procedure Variables
Assignment to a procedure variable has a different syntax
on each of the two architectures.
On the Series 300/400, the maximum string size is 255 characters.
By specifying the LONGSTRINGS compiler option,
maximum string size is virtually unlimited.
The string size on Series 700/800 is unlimited.
ANYVAR is supported on all HP-UX implementations.
Series 300/400 does not perform checks to see
if ANYVAR values are legitimate.
Series 700/800 passes size information with ANYVAR parameters.
On the Series 300/400,
elements of packed arrays can be passed as ANYVAR parameters
if you use the ALLOW_PACKED compiler option.
All HP-UX implementations support structured constants
but different restrictions may apply.
Series 300/400 restricts their use to the CONST section
and it does not do full type checking on variant-record structured constants.
There is a small difference in precision
between the implementations of longreal
because different bit-patterns are used.
anyptr, globalanyptr, and localanyptr
All HP-UX implementations have anyptr,
although minor differences exist.
On Series 700/800, anyptr is only assignment compatible,
it is not type compatible with pointer types.
anyptr is also a different size on Series 700/800: it is 64 bits.
globalanyptr and localanyptr are implemented only on Series 700/800.
Program parameters have slight semantic differences
between Series 300/400 and Series 700/800.
Arguments for the + operator with strings differ
between Series 300/400 and Series 700/800.
For example, chr cannot be used with + on Series 700/800.
Series 300/400 and Series 700/800 each generate different listings.
Features Supported only on Series 300/400You can use the addr function to get the address of a constant.
A procedure alias is evaluated before addr(alias) is performed.
packed array of char does not require a lower bound of one
for some operations.
Features Supported only on Series 700/800waddress accepts NIL or a NIL-valued pointer.
A label is not allowed on the statement following a recover statement.
readonly parameters are allowed.
crunched arrays and records are allowed.
The following built-in functions are available:
haveextension
haveoptvarparam
statement_number
susizeof
|
The assert procedure is defined.
lobound subrange expressions that start with "(" are allowed.
Source is scanned that has been conditionally compiled out.
This allows NLS characters in conditionally compiled sections of the source.
$STANDARD_LEVEL 'HP_MODCAL'$ must be used before importing an argument.
You must compile with $STANDARD_LEVEL 'EXT_MODCAL'$
to convert a pointer to an integer with ord(pointer_type),
packed array of char requires a lower bound of one.
Command-Line Options |  |
Table 1-7 “Command-Line Options Specific to Series 300/400” summarizes the command-line options
that are available only on the Series 300/400
or that behave differently on the Series 700/800.
Table 1-7 Command-Line Options Specific to Series 300/400 Command Option | Effect
|
|---|
+A | Use 2-byte alignment rules.
| +bfpa | Affect floating-point operations.
| +ffpa | Affect floating-point operations.
| +l | Allow production of dynamically loaded libraries.
| -L | Produce a program listing in a file specified
by $LIST filename$.
| +M | Use library calls for floating point.
| +S | Use 4-byte alignment rules.
| -T | Same as $TABLES ON$.
| +U | Same as $ALLOW_PACKED ON$.
|
Table 1-8 “Command-Line Options Specific to Series 700/800” summarizes the command line compiler options
that are available only on the Series 700/800
or that behave differently on the Series 300/400.
Table 1-8 Command-Line Options Specific to Series 700/800 Command Option | Effect
|
|---|
+C
| Convert MPE file names to HP-UX names.
| +DAmodel
| Generate object code for a particular version of the PA-RISC architecture.
| +DSmodel
| Perform instruction scheduling
tuned for a particular implementation of the PA-RISC architecture.
| -L
| Produce a program listing to stdout.
| +N
| Turn off generation of notes.
| +O0, +O1, +O2, +O3, +O4
| Set optimization level.
| +O[no]aggressive,
+O[no]all,
+O[no]conservative,
+O[no]limit,
+O[no]size,
+O[no]entrysched,
+O[no]fastaccess,
+O[no]fltacc,
+O[no]initcheck,
+O[no]libcalls,
+O[no]moveflops,
+O[no]pipeline,
+O[no]procelim,
+O[no]regionsched,
+O[no]regreassoc
| Modify optimization.
| -S
| Produce assembly output.
| +k
| Generate long-displacement code sequences for referencing global data.
| -y
| Generate additional information needed by static analysis tools.
| +z and +Z
| Produce PIC object for shared libraries.
|
Compiler Options |  |
The HP Pascal/HP-UX compilers support a wide range of compiler options.
Some options are identical on all systems.
Some options are unique to a particular system.
Some options have different semantics
and slightly different syntax from one system to the other.
For portable code,
keep compiler options to a minimum and avoid options
that affect the semantics of the language
or enable system level programming extensions.
For example, avoid using the $SYSPROG$ option on the Series 300/400.
Table 1-9 “Compiler Options Specific to Series 300/400” lists options that are specific to Series 300/400
as well as options that have the same name on Series 700/800
but different semantics.
Table 1-9 Compiler Options Specific to Series 300/400 | Compiler Option | Effect |
|---|
ALLOW_PACKED
| Allows ANYVAR parameter passing of fields in packed records and arrays,
and SIZEOF using packed fields and arrays.
| ANSI[1]
| The compiler issues an error message
when it encounters a feature in the source code
that is illegal in ANSI/ISO Standard Pascal.
It must be placed at the top of the file.
| CODE[1]
| Selects whether a code file is generated.
This option is not allowed within a procedure body.
| CODE_OFFSETS[1]
| Causes PC offsets to be included in the listing.
This option is not allowed within a procedure body.
| DEBUG
| Causes line number debugging information to be included in the object code.
| FLOAT_HDW
| Controls generation of code for floating-point hardware.
| IF/ELSE/ENDIF[1]
| Controls conditional compilation.
Refer to the HP Pascal/HP-UX Reference Manual; for the Series 300/400 for details.
| LINENUM
| Sets listing line number.
| LINES[1]
| Specifies number of lines per page on a listing.
Default value is 60.
| LITERAL_ALIAS[1]
| Determines the case-sensitivity of an alias name.
| LONGSTRINGS
| Extends the maximum length of strings from 255 characters to virtually any length.
| RANGE[1]
| Does run-time checks for range errors.
| SAVE_CONST
| Controls scope of structured constants.
| SEARCH[1]
| Specifies files to be used to satisfy IMPORT declarations.
This option must be the last option on an option list.
| SEARCH_SIZE
| Changes number of external files that can be searched.
The default is 9.
| STANDARD_LEVEL[1]
| Defines the compatibility level with various versions of Pascal.
| TABLES[1]
| Turns on the listing of symbol tables.
TABLES cannot be used within a procedure body.
| UNDERSCORE
| Causes ALIAS parameters to have an underscore added as a prefix.
| XREF[1]
| Used with LIST ON, the listing includes a cross reference for each
function, procedure, and outer block.
|
Table 1-10 “Compiler Options Specific to Series 700/800” lists options that are specific to Series 700/800
as well as options that have the same name on Series 300/400
but different semantics.
Table 1-10 Compiler Options Specific to Series 700/800 | Compiler Option | Effect
|
|---|
ALIGNMENT
| Changes storage alignment for types other than strings and file types.
| ANSI[1]
| The compiler issues an error message when it encounters a feature in
the source code that is illegal in ANSI Standard Pascal.
$ANSI ON$ is equivalent to $STANDARD_LEVEL 'ANSI'$.
| ASSERT_HALT
| Causes the program to halt if the assert function fails.
| ASSUME
| Sets optimizer assumptions.
| BUILDINT
| Causes the compiler to build an intrinsic file rather
than an object code file.
| CHECK_ACTUAL_PARM
| Sets level of type checking of actual parameters
for separately compiled functions or procedures.
| CHECK_FORMAL_PARM
| Sets level of type checking of formal parameters
for separately compiled functions or procedures.
| CODE[1]
| Generates object code after parsing a compilation block.
| CODE_OFFSETS[1]
| When $LIST ON$ is used, the compiler prints a table
that contains the statement number and offset of each executable statement
that it lists.
| CONVERT_MPE_NAME
| Converts file names in the BUILDINT, INCLUDE, LISTINTR,
and SYSINTR compiler options from MPE format to HP-UX format.
| COPYRIGHT
| Causes a copyright string to be placed into object code.
| COPYRIGHT_DATE
| Sets the date that appears in the copyright notice.
This option must be used with the COPYRIGHT compiler option.
| EXTERNAL
| Used in conjunction with the GLOBAL option, EXTERNAL
enables you to compile one program as two or more compilation units.
| EXTNADDR
| Specifies long pointer accessing.
| GLOBAL
| Used in conjunction with the EXTERNAL option,
GLOBAL enables you to compile one program as two or more compilation units.
| GPROF
| Generates code for profiling.
| HEAP_COMPACT
| When used with HEAP_DISPOSE ON, free space in the heap is concatenated.
| HEAP_DISPOSE
| The predefined procedure dispose frees space in
the heap so that the predefined procedure new can reallocate it.
| HP_DESTINATION
| HP_DESTINATION 'ARCHITECTURE'
generates object code for a particular version of of the PA-RISC architecture.
HP_DESTINATION 'SCHEDULER'
performs instruction scheduling tuned for a particular implementation
of the PA-RISC architecture.
| IF/ELSE/ENDIF[1]
| Controls conditional compilation.
Refer to the HP Pascal/HP-UX Reference Manual; for the Series 700/800 for details.
| INLINE
| Causes a procedure call to be replaced by inline code.
| KEEPASMB[1]
| Causes the compiler to preserve an assembly file for the source file.
| LINES
| Specifies number of lines per page on a listing.
Default value is 59.
| LIST_CODE
| When used with LIST ON, a mnemonic listing of object code is produced.
| LISTINTR
| List an intrinsic file to a specified file.
| LITERAL_ALIAS[1]
| $LITERAL_ALIAS ON$ causes the compiler to differentiate between
uppercase and lowercase letters for aliases.
$LITERAL_ALIAS OFF$ causes the compiler to downshift aliases.
| LOCALITY
| Causes a locality name to be written to the object file for performance.
| MLIBRARY
| Specifies an alternate file into which the module export text
is to be written.
| NOTES
| Causes helpful compiler notes to be printed on the program listing.
| OPTIMIZE
| Sets the level of optimization.
| OS
| Specifies the operating system under which a program is to be run.
| RANGE[1]
| The compiler generates range-checking code.
| S300_EXTNAMES
| Changes external names to a form consistent with
Series 300/400 conventions.
| SEARCH[1]
| Specifies one or more files for the compiler to search
for module definitions.
| SHLIB_CODE
| Generates PIC object code that you can use to create libraries.
| SKIP_TEXT
| Causes the compiler to ignore source code.
| STANDARD_LEVEL[1]
| Defines the compatibility level with various versions of Pascal.
| STATEMENT_NUMBER
| When enabled, the compiler generates a special instruction
to identify a code sequence with its corresponding Pascal statement.
| SUBPROGRAM
| Causes the compiler to emit code for specified level-one routines only.
This option enables you to compile selected routines of a program.
| SYMDEBUG
| Emits debugger information for xdb.
| SYSINTR
| Specifies the intrinsic file to be searched
for information on intrinsic routines.
| TABLES[1]
| When used with LIST ON,
the listing includes an identifier map for each compilation block.
| TITLE
| Specifies the title to appear on subsequent pages of the program listing.
| UPPERCASE
| All external names, including aliases, are shifted to uppercase.
| VERSION
| Specifies a version stamp to be placed in the object file.
| XREF[1]
| When used with LIST ON,
the listing includes a cross reference
for each function, procedure, and outer block.
|
|