pTAL Reference Manual (H06.03+)

HP pTAL Reference Manual523746-005
D-1
D
RETURN, RETURNSCC, and C/C++
on TNS/E
Read this appendix if you write or call pTAL procedures that:
Return both:
°
A traditional function value by means of the RETURN statement
°
An unrelated condition code value by means of the RETURNSCC attribute
And are called by C or C++ procedures
On the TNS architecture, a TAL procedure can return both a traditional function value
and an unrelated condition code value. Both return values are accessible after the
procedure call. pTAL procedures emulate this behavior on both the TNS/R and TNS/E
architectures, but C/C++ procedures do not.
On the TNS/R architecture, if a C/C++ procedure calls a pTAL procedure that returns
both a traditional function value and a condition code value, the C/C++ compiler issues
an error message.
Some programmers work around this C/C++ compile-time error by writing C/C++
prototypes that rely on the knowledge that on the TNS/R architecture, pTAL object
code stores the two return values in a single 64-bit value. After the C/C++ procedure
calls the pTAL procedure, it extracts from the 64-bit value either both return values
(see Example D-1 on page D-2) or only the traditional function value (see Example D-2
on page D-3).
The EpTAL compiler issues a warning whenever a pTAL procedure returns both a
traditional function value and a condition code value. To migrate such a procedure to
TNS/E, HP recommends that you:
1. Write a pTAL shell procedure that returns the two values in the way that C/C++
returns them (in Example D-3 on page D-3, this procedure is P_SHELL).
2. Change the alias of the C/C++ prototype to the name of the pTAL shell procedure
in Step 1. (This change eliminates the need to change the calls to this prototype.)
3. Retire the original pTAL procedure linkage name. This allows the eld utility to
identify any uses of unchanged C/C++ prototypes, instead of producing an
executable program that uses the old prototypes (because the eld utility does not
produce an executable program if there are unresolved procedure references).
Caution. C/C++ prototypes such as these are not guaranteed to work on the TNS/R
architecture, and extracting only the traditional function value (as in Example D-2 on page D-3)
does not work on the TNS/E architecture.