Open System Services Porting Guide (G06.24+, H06.03+)

Table Of Contents
Interoperating Between Programming Environments
Open System Services Porting Guide520573-006
5-15
Design Considerations and Steps
the SYSTYPE pragma to direct the compiler to generate code appropriate for each
environment. Specify SYSTYPE OSS for OSS modules and SYSTYPE GUARDIAN for
Guardian modules. Using mixed-module programming should be minimized because
of the knowledge required to keep code easier to maintain.
The SYSTYPE pragma also defines the appropriate feature-test macros for each
environment. Feature-test macros and pragmas are discussed more in OSS C
Programming Considerations on page 7-10. More information about mixed-module
programming can be found in the C/C++ Programmer’s Guide.
Design Considerations and Steps
When designing mixed-module programs, the first task is to decide on whether your
program will run as an OSS process or a Guardian process. Guardian objects are
manipulated from the Guardian module and OSS objects are manipulated from the
OSS module. If the majority of a program’s code uses the resources of and
manipulates objects in the Guardian environment, consider writing the program as a
Guardian process. Likewise, if the majority of a program’s code uses the resources of
and manipulates objects in the OSS environment, consider writing the program as an
OSS process. Other factors, such as the availability of resources and services unique
to each environment, can also influence your decision.
After deciding on the environment in which a program runs, choose a development
environment. The development environment is the environment in which you compile,
link, and optimize (or accelerate) the program. While you can develop a program in
one environment that runs in the other environment, it is easier to develop a program in
the environment in which will run.
After choosing the development environment, you can begin writing the program. Write
the program’s main() function in the environment in which the process runs; write
code for the other environment only when necessary, and then place it in separate
modules.
For TNS interpreted and accelerated programs, both Guardian and G-series OSS
modules must use the 32-bit (or WIDE) data model and the large-memory model (the
size of a pointer and type int is 32 bits). For TNS/R and TNS/E native programs, both
Guardian and OSS modules use the same data and memory models, so there is no
concern for mixing different models.
Mixed-Language Programming
The Common Run-Time Environment (CRE) coordinates many run-time tasks on
behalf of the run-time libraries, thus providing a common environment for all routines in
a program, regardless of language. The CRE provides services that significantly
enhance your ability to create mixed-language programs.
Note. You must compile Guardian and OSS modules separately (on the command line, not in
source code). The c89 utility cannot compile two modules with different SYSTYPE values.