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

To call a C++ function from another language, call the C++ function as if it were a C function but
use the encoded name form. Get this encoded name form from the C source file that is created by
Cfront.
If you want to call a function written in another language from a C or C++ program, your program
must have a C main function.
You do not need to put the extern C construct around #include <cextdecs> because the extern
C construct has already been added to the <cextdecs> header file for use by C++.
System-Level Programming
C++ supports system-level programming. System-level programming refers to the ability to write
C++ functions that reside in system code, system library, or user library. Refer to Chapter 9:
System-Level Programming.
Differences Between OSS and Guardian Environments
The OSS and Guardian versions of Cfront each default to generate code that is destined to run in
their own environment. This subsection discusses how to target code to run in the other environment
and describes the differences that exist between an executable C++ program file in the two
environments.
Pragma SYSTYPE
The pragma SYSTYPE specifies whether a C++ program is targeted to run in the OSS or the
Guardian environment.
The Guardian version of Cfront defaults to generating code that is targeted for the Guardian
environment. However, when the pragma SYSTYPE OSS is specified, the Guardian version of
Cfront generates code targeted for the OSS environment.
The OSS version of Cfront defaults to generating code that is targeted for the OSS environment.
However, when the pragma SYSTYPE GUARDIAN is specified, the OSS version of Cfront generates
code targeted for the Guardian environment.
Data Models
C++ programs that are generated with the OSS version of Cfront always use the 32-bit data model.
Under the 32-bit data model the size of type int is 32 bits. C++ programs that are generated with
the Guardian version of Cfront also default to the 32-bit data model. Therefore, the data models
will be compatible unless you specify the NOWIDE pragma when compiling the Guardian version.
The NOWIDE pragma specifies the 16-bit data model, where the size of type int is 16 bits.
If 16-bit and 32-bit data are both required, you might want to avoid type int and use types short
and long instead.
Run-Time Libraries
The OSS environment has only one C++ run-time library, libC.a.
The Guardian environment has two run-time libraries. LIBCA is used with the 32-bit data model.
LIBLA is used with the 16-bit data model.
Applicable Pragmas
In the OSS environment, the C compiler ignores these pragmas: ANSISTREAMS, RUNNABLE,
SEARCH, SSV, STDFILES, and XVAR.
For additional information on writing programs for the OSS environment, see Chapter 14:
Compiling, Binding, and Accelerating TNS C Programs, and Chapter 15: Compiling, Binding,
and Accelerating TNS C++ Programs.
420 TNS C++ Implementation-Defined Behavior