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

for (p = name; i <= LAST_NAME ; i++, p = &name[i])
if (!strcmp(p, "kevin"))
return TRUE;
return FALSE;
}
Note the inclusion of pragma inline in the preceding compilation unit. Because the passing of
pointers to code space is hazardous for the run-time function call of strcmp, generation of inline
code is safer.
You can also place constants in the code space with the _cspace type qualifier. However, the
_cspace type qualifier is effective only on the specified data constant. Other constants in the
function without the type qualifier are still allocated in the static data space. The use of the _cspace
qualifier under the ENV LIBRARY or ENV LIBSPACE pragmas is redundant for object definitions
with the type qualifier const, except for pointers. For example, you must specify _cspace in this
declaration to store the object in the code space, regardless of specified ENV pragma:
#pragma env libspace
const char * lvar = "x"; /* Stored in data space */
const _cspace char * hvar = "y"; /* Stored in code space */
1. This example declares the arr constant array to be located in the current code space:
_cspace const char arr[] = "ABCD";
2. This example declares a pointer data type to point to a constant item located in the code
space:
extern _cspace const int * ptr;
If you apply the & operator to a constant stored in the code space, the result is a 32-bit extended
pointer.
Writing Variable and Extensible Functions
Variable and extensible functions are HP extensions to the ISO/ANSI C language standard. This
subsection describes how to use variable and extensible functions, including:
Declaring variable functions with the variable attribute
Declaring extensible functions with the extensible attribute
Checking for actual parameters with the _arg_present() operator
Omitting parameters on calls to variable and extensible functions
Converting variable functions to extensible functions
For a complete syntax description for writing variable and extensible function declarations, see
FUNCTION (page 195).
For native C, variable and extensible functions are treated the same. The semantics used are those
for extensible functions. Therefore, declare procedures extensible instead of variable in native C
programs. This discussion about variable and extensible functions applies only to TNS C and C++,
not to native mode.
Declaring Variable Functions
The variable attribute directs the compiler to treat all parameters of a function as though they
are optional, even if some are required by your code. If you add parameters to a variable function
declaration, all procedures that call it must be recompiled. This example declares a variable
function:
foo(int i, int j, int k);
#pragma function foo (variable)
{ ... /* foo declaration */ }
146 System-Level Programming