C/C++ Programmer's Guide (G06.25+)

Mixed-Language Programming for TNS/R and
TNS/E Native Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-008
8-21
Considerations When Interfacing to pTAL
Differences between pTAL and C pointers include the following:
pTAL structure pointers can point to a byte or word address.
C structure pointers always point to a byte address.
pTAL pointers are dereferenced implicitly.
Here are examples of pTAL and native C pointers:
pTAL Code C Code
STRUCT rec (
*
); struct rec
BEGIN {
INT d; short d;
INT .p (rec); struct rec *p;
END; };
BLOCK joe;
INT .EXT joes (rec); struct rec *JOE;
END BLOCK;
PROC tonga (p); void CALEDONIA
INT .EXT p (rec); (struct rec *p)
BEGIN {
!Lots of code /* Lots of code */
END; }
Each language can call the other, passing the address in the pointer by value:
pTAL Code C Code
CALL caledonia (joes); TONGA (joe);
Here are examples of pTAL and C structure pointers (large-memory model) that
implement a linked list:
pTAL Code C Code
STRUCT rec (
*
); struct rec
BEGIN {
INT x; short x;
INT .EXT strptr (rec); struct rec *p;
END; };
STRUCT .EXT joe (rec); struct rec joe;
PROC callme (param1); void f1 (struct rec *param1);
INT .EXT param1 (rec);
EXTERNAL;
Enumeration Variables
Using C enumeration variables, you can associate a group of named constant values
with an int variable. A C enumeration variable occupies 16 bits of memory for TNS
programs and 32 bits for native programs. You define all integer operations on them.
The C compiler provides no range checking, so an enumeration variable can hold a
value not represented in the enumeration.