C/C++ Programmer's Guide (G06.27+, H06.03+)

Table Of Contents
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
9-1
9 System-Level Programming
Specifying a Code Space
Passing Pointers to Constants Between Code Spaces on page 9-2
Writing Variable and Extensible Functions on page 9-4
°
Declaring Variable Functions on page 9-5
°
Declaring Extensible Functions on page 9-5
°
Checking for Actual Parameters With _arg_present() on page 9-5
°
Omitting Parameters on page 9-6
°
Converting Variable Functions to Extensible Functions on page 9-6
System-level programming refers to the ability to write TNS C and C++ functions that
reside in system code, system library, or user library. It also refers to native C and C++
functions that reside in user library. Customer-written native C and C++ functions
cannot reside in system code or system library. System-level programming is available
only in the Guardian environment.
Specifying a Code Space
A code space is a part of virtual memory that is reserved for user code, user library
code, system code, and system library code. Depending upon the code space, the C
compiler generates different code and places different restrictions on your code. Use
the ENV pragma to specify the code space.
To compile functions to run in system code, specify ENV EMBEDDED. To compile
functions to run in system library, specify ENV LIBSPACE. To compile functions to run
in user library, specify ENV LIBRARY. For more details, see the description of the
pragma ENV on page 13-20.
For each code space, there are restrictions on the run-time library and language
features that can use be used. Table 9-1 summarizes the availability of run-time library
and language features for each code space.
Table 9-1. Code Spaces and the Availability of Run-Time Library and Language
Features (page1of2)
Feature System Code User Library System Library
C I/O functions No Yes * No
Memory allocation functions No Yes No
Main routine NoNoNo
Relocatable data blocks Yes No No
Functions that set errno No Yes No
* TNS C and C++ programs can use functions in a user library if direct access to relocatable data blocks is not
needed for the operations. Native C and C++ programs in a user library can use any C library function.
**The _cspace type qualifier lets you allocate constants in the code space.