Open System Services Porting Guide (G06.29+, H06.06+, J06.03+)
Compiling and Linking Programs From OSS
There are two native-mode C compilers: one runs in the OSS environment and one runs in the
Guardian environment. Each compiler compiles OSS and Guardian programs and produces
identical code. However, each compiler has different default pragma settings.
Compiling and linking programs for the OSS environment is done using the c89 or the c99 utility,
a compilation driver program. OSS uses a naming convention in which a name is formatted into
two parts, separated by a period. The first part is a name chosen by the user; the second part is
a one-letter suffix, identifying the file’s contents. For C programming, the most common suffixes
are:
DescriptionSuffix
C source filec
Header or include fileh
Compiled but unbound code, usually referred to as an “object file”o
Examples
The following command compiles the C source code file testprg.c. By default, c89 produces
the executable a.out file:
c89 testprg.c
The Guardian equivalents to this example would be similar to the following commands, which
produces an executable file called OBJECT by default. (The code produced in each environment
is not identical, but equivalent in function.)
TNS/R native:
NMC /IN TESTPRGC, OUT LISTFILE/ AOUT; RUNNABLE
TNS/E native:
CCOMP /IN TESTPRGC, OUT LISTFILE/ AOUT; RUNNABLE
The TNS C compiler equivalent would be:
C /IN TESTPRGC, OUT LISTFILE/ AOUT; RUNNABLE, WIDE
In the following example, the first and second command lines compile the C source code files
test1.c and test2.c. The -c flag specifies the creation of only object files: test1.o and
test2.o. The third command line binds the two object files together to create an executable file.
The -o flag specifies the name of the executable file (tester) to produce:
c89 -c test1.c
c89 -c test2.c
c89 -o tester test1.o test2.o
The Guardian TNS/R native equivalent is similar to the following:
NMC /IN TEST1C, OUT LIST1/ TEST1o
NMC /IN TEST2C, OUT LIST2/ TEST2o
NLD -o TESTER TEST1o TEST2o
The Guardian TNS/E native equivalent is:
CCOMP /IN TEST1C, OUT LIST1/ TEST1o
CCOMP /IN TEST2C, OUT LIST2/ TEST2o
ELD -o TESTER TEST1o TEST2o
Using the Guardian TNS C compiler tools, the equivalent would be:
C /IN TEST1C, OUT LIST1/ TEST1o; WIDE
C /IN TEST2C, OUT LIST2/ TEST2o; WIDE
BIND /IN TESTERB/
The contents of the file TESTERB would be as follows:
SELECT CHECK PARAMETER OFF
ADD * FROM TEST1O
OSS Commands for the Guardian User 61