PL/I

PL/I

PL/I

 View Only
Expand all | Collapse all

Calling PL/I from COBOL with variadic arguments

  • 1.  Calling PL/I from COBOL with variadic arguments

    Posted Thu August 14, 2014 04:41 PM

    Hi,

    I have a PL/I routine for processing (formatting & writing) messages. It takes a variable number of arguments via the "LIST" attribute on the last declared argument.

    This allows me to use VARGLIST() and VARGSIZE() builtin functions to step through the optional parameters. This all works.

     

    Now I am trying to call this from a COBOL program, but once I added the OPTIONS(COBOL) I get compiler errors telling me that the LINKAGE is incompatible with the "LIST" attribute.

    Normally, when I run into restrictions it's easy to figure out why they exist (and sometimes get past them).

    This one has me stumped. I know that COBOL does not directly support variable length parameter list, but it also does not prohibit them.

    From COBOL, you can call an external entry point any number of times, passing a different number of arguments each time. It's up to the called program to correctly handle the variadic data.

    Why is LIST (variadic parameters) prohibited for COBOL linkage in PL/I?

    Is there another way to accomplish this?

    Frank 

    Frank_O_Myers@IBM


  • 2.  Re: Calling PL/I from COBOL with variadic arguments

    Posted Fri August 15, 2014 12:06 PM

    I removed the LIST attribute, and now pass the last argument as POINTER BYVALUE, and will try getting it's address and stepping past it to retrieve the next parameter using

    POINTERADD(ADDR(lastparameter),SIZE(APOINTER))

    This should (I hope) allow me to retrieve sucessive full-word pointers or values from the caller's parameter list.

    Frank_O_Myers@IBM


  • 3.  Re: Calling PL/I from COBOL with variadic arguments

    Posted Mon August 25, 2014 11:41 AM

    I found that I can simply override the linkage, and the LIST works.

    Frank_O_Myers@IBM