Open System Services Porting Guide (G06.29+, H06.06+, J06.03+)
header files are in /usr/include and its subdirectories by default. Because the OSS C compiler
requires that header files use the OSS pathname syntax, all header files must be specified in this
syntax. All uses of #include preprocessor directives in the Guardian C source program must be
modified, if necessary, to use the OSS pathname syntax. Simple file names like stdio.h are
correct in both environments, but names traditionally containing relative paths are condensed into
a single Guardian name. For example, the file named sys/types.h in OSS is named
systypes.h in Guardian.
The use of header files is optional (but strongly recommended) for programs that contain Guardian
modules exclusively. However, using header files is required for mixed-module programs: for
example, when an OSS module is bound into a Guardian program. If compilation is done without
using header files, the linker cannot correctly resolve external references to some Guardian and
OSS functions.
NOTE: The native C compilers can be directed to accept C source files conforming to Kernigan
and Ritchie (K&R) C or Common C in addition to ISO/ANSI C. However, HP does not provide a
complete set of header files that conform to K&R C. The user must modify existing header files or
obtain files from another source to compile K&R C source files.
Include File Search Order
In the Guardian environment, the SSV pragma specifies a search list of subvolumes for files specified
in the #include directives. In the OSS environment, the -I flag with the c89 or c99 utility specifies
a search list of directories for files specified in #include directives. Refer to the c89(1) or the
c99(1) reference page either online or in the Open System Services Shell and Utilities Reference
Manual for the details.
Using Pragmas
Some of the compiler pragmas used in Guardian C or C++ programs do not apply to programs
compiled in the OSS environment; they are ignored or generate an error when the c89 or c99
utility is used.
You can remove these pragmas from the source files if you compile with the c89 or c99 utility:
Generate executable object file.RUNNABLE
Search object file to resolve external references (used with runnable).SEARCH
Specify list of search subvolumes for files in #include directives.SSV
Select small memory model (TNS only).NOXMEM
Select 16-bit data model (TNS only).NOWIDE
Preprocessor Symbols
The native and TNS C compilers provide three predefined preprocessor symbols: __TANDEM,
__INT32, and __XMEM.
You can use __TANDEM to increase the portability of your C programs. (Enclose system-dependent
source text in a section that uses #ifdef or #ifndef directives to test for the existence of
__TANDEM.)
For the TNS environment, __INT32 (for int defined as 32 bits) is defined by the C compiler when
the WIDE pragma is present; __XMEM (for the large-memory model) is defined by the C compiler
when the XMEM pragma is present. For the native environment, these two symbols are always
defined.
These preprocessor symbols are set by default when the OSS C compiler is invoked with the
-Wsystype=guardian flag. Other symbols can be set by using the appropriate flags in the c89
or c99 command line, or the appropriate pragmas in the C or C++ source code.
C Compiler Issues for Guardian Programs 141