C/C++ Programmer's Guide (G06.25+)
Mixed-Language Programming for TNS Programs
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
7-3
Using Standard Files in Mixed-Language Programs
routines in a program to run in the CRE. In contrast, TAL routines must call CRE library 
routines directly.
For information on writing programs that use the services provided by the CRE, see 
the Common Run-Time Environment (CRE) Programmer’s Guide. For details on 
specifying a run-time environment, see the description of pragma ENV on page 13-19. 
For details on mixed-language binding, see Restrictions on Binding Caused by the 
ENV Pragma on page 14-10.
Using Standard Files in Mixed-Language 
Programs
In a mixed-language program, if a TNS C function is to be the main function, it should 
be compiled with the NOSTDFILES pragma to keep it from automatically opening the 
three standard C files: stdin, stdout, and stderr.
If the main routine is not written in C, the three standard C files will not be automatically 
opened. If you want any or all of the standard files to be opened for C, you must 
explicitly open them by calling the fopen_std_file() function.
Writing Interface Declarations
Your TNS C programs can call procedures written in C++, COBOL, FORTRAN,
D-series Pascal, and TAL, as well as procedures written in an unspecified language 
type. You cannot mix TNS and native-mode language modules.
All external procedures must be declared. The interface declaration indicates the 
correct language or indicates "unspecified," if the language is unknown. If the language 
is unspecified, then the external procedure is assumed to be written in C.
Because lexical and operational features differ between C and these other languages, 
you must use an interface declaration instead of a simple function declaration to 
declare a procedure written in one of these other languages. Interface declarations are 
an HP extension to the ISO/ANSI C standard for function declarations. They provide 
additions that account for most of the differences between C and the other language.
The modern, preferred method for writing an interface declaration is to use a standard 
function prototype followed later by a FUNCTION pragma. This is the general form:
int NAME (<params>);
...
#pragma function NAME (params)
For details on syntax, see pragma FUNCTION on page 13-36. For an illustration of a 
FUNCTION pragma used in an interface declaration, see the examples following this 
discussion.
The older method for declaring procedures is to declare the procedure just as you 
would a C function, except that you include:










