Adding New Versions to a Shared Library

To rebuild a shared library with new versions of some of the object files, use the aCC command and the -boption with the old object files and the newly compiled object files. The new source files should use the HP_SHLIB_VERSION pragma. Refer to HP-UX Online Linker and Libraries User’s Guide for more information.

Standard HP-UX Libraries and Header Files

HP-UX includes Several libraries that provide system services. You can access HP-UX standard libraries by using header files that declare interfaces to those libraries. Refer to the HP-UX Reference Manual for more information on library routines.

Location of Standard HP-UX Header Files

The standard HP-UX header files are located in /usr/include directory.

Using Header Files

To use a system library function, your HP aC++ source code must include the preprocessor directive #include.

Example:

#include <filename.h>

where filename.h is the name of the C++ header file for the library function you want to use. By enclosing filename.h in angle brackets, the HP aC++ compiler looks for that particular header file in a standard location on the system. The compiler first looks for header files in /opt/ aCC/include directory. When no header files are found in this directory, it searches /usr/ includeUse header file options to modify the search path..

Example

To use the getenv function that is in the standard system libraries (/usr/lib/libc.so and /usr/lib/libc.a), specify:#include <stdlib.h>

because the external declaration of getenv is found in the header file /usr/include/stdlib.h.

Allocation Policies for Containers

By default, allocating memory for STL containers is optimized for large applications. Defaults have been tuned with speed efficiency as a primary concern. Space efficiency was considered, but was secondary. Typically, therefore, memory is not allocated as required, because this method is slow and inefficient. The containers obtain a block of memory to hold many elements, and when this fills up, they get another block. The size of the block depends on the element size. As a result, containers with only a few items might end up allocating too much memory. This default behavior can be adjusted to individual application needs.

For -AP Standard Library

The inline template function__rw_allocation_size can be explicitly specialized to return the number of units for each type’s use in any container:

template <>

inline size_t __rw-allocation_size(bar*,size_t) { return 1;

}

This would initially allocate one unit when dealing with containers of type bar. Alternatively, if RWSTD_STRICT_ANSI is not defined, then container member functionallocation_size can be used to directly set buffer_size, the number of units to allocate.

184 Tools and Libraries

Page 184
Image 184
HP C/aC++ for PA-RISC Software manual Standard HP-UX Libraries and Header Files, Allocation Policies for Containers