Chapter Contents

Previous

Next
Simple Interlanguage Communication

Calling a MAIN Routine in Another Language from C

Calling a MAIN routine in another language from a C program is also fairly straightforward. Call the other language at the entry point described in the documentation for the other language. For example, PL/I is called at PLISTART, PLICALLA, or PLICALLB. You must build a parameter list or parameter block in the format expected by the implementation of the other language and pass its address in the manner expected by the other language. In most cases, you use the standard OS/390 parameter list format. For some languages, such as PL/I, you may be able to handle parameter passing with C code; for others, you may need to write an assembler stub to do it. Use of the @ operator or the __ref keyword can assist you in building a call-by-reference parameter list. See Communication with Assembler Programs for more information on these features.

Because you are calling a MAIN routine, the other language's execution framework is set up before the other language program receives control, and it is terminated when the other language routine ends. You do not need to be concerned with the details of the other language's framework. You can call subroutines in the other language from the other language's MAIN routine, and you also can call assembler subroutines (subject to the restrictions imposed by the other language). However, you cannot call C functions from other languages. If you need to do this, use the ILC feature or the techniques described in Using the indep Option for Interlanguage Communication.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.