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

Compiling a Module
The native compilers translate the source text of a module and produce:
An extensive compiler listing. Several pragmas enable you to control the content of this compiler
listing.
A nonexecutable object file, if the compiler encountered no errors during the compilation.
After compiling all the modules that compose your program, you collect and combine them into a
program file (an executable object file) by using the nld utility for conventional code or the ld
utility for PIC (Position-Independent Code).
If your program comprises a single module, you can use the RUNNABLE pragma to direct the
compiler to produce a program file instead of a nonexecutable object file.
If your program comprises more than one module, you can use the RUNNABLE and LINKFILE
pragmas to direct the compiler to produce a linked program file instead of a nonexecutable object
file. For more details, see pragma LINKFILE (page 213).
To use the RUNNABLE pragma, one of the modules must contain the main function of the program.
When you specify the RUNNABLE pragma, the native C and C++ compilers specify the
$SYSTEM.SYSTEM.LIBCOBEY command file to the linker. The LIBCOBEY file directs TNS/R native
linker to link to a set of standard shared run-time libraries (SRLs). For most C and C++ programs,
this set of SRLs is sufficient to create an executable program. If your program requires SRLs not
specified in LIBCOBEY (such as the Tools.h++ SRL) you can direct TNS/R native linker to search
additional SRLs using the LINKFILE pragma.
The NMC command invokes the TNS/R native C compiler. The NMCPLUS command invokes the
TNS/R native C++ compiler. The syntax for these commands is shown in this diagram.
[ RUN ] { NMC | NMCPLUS } / IN source [ , OUT listing ]
[ , run-options ] / [ object ]
[ ; compile-option [ , compile-option ]... ]
compile-option:
{ pragma }
{ define identifier [ constant ] }
{ undefine identifier }
[ RUN ] NMC
is the TACL command to start the TNS/R native C compiler process. The RUN command keyword
is optional.
[ RUN ] NMCPLUS
is the TACL command to start the TNS/R native C++ compiler process. The RUN command
keyword is optional.
IN source
specifies the primary source file of the module. The file must be a valid Guardian file name for
either a type 101 (EDIT) or type 180 disk file. Interactive input from a terminal or a process is
not accepted.
OUT listing
specifies the file to which the TNS/R native C compiler writes the compiler listing. When
specified, listing is usually a spooler location. If you omit the OUT option, the compiler
writes the listing to your current default output file. If the file already exists, the compiler attempts
to delete the file and then continue.
292 Compiling and Linking TNS/R Native C and C++ Programs