C and C++ parameter passing considerations
C and C++ generally
support a single character string as a parameter to a main routine.
They parse the string into tokens that are accessed by the argc and argv parameters
of the main function.
In addition, there are alternate styles of passing a set of parameters to the main routine, for example: as a single value, a pointer to a value, or a pointer to a list of values. In these cases, the set of parameters is not parsed. It is assumed that the invoker of the application (for example, the operating system) has stored the address of the set of parameters in register 1 before entry into the main routine. Depending on how the parameters are passed, register 1 points on entry to the entities illustrated in Figure 1:

The first arrangement in Figure 1 can be used only for parameters that are integers.
#pragma runopts (see C PLIST and EXECOPS interactions); a C++ routine
elects to use one of the styles with the PLIST(OS) compiler option
(see C++ PLIST and EXECOPS interactions). The main routine
must know which parameter style to expect. When PLIST(OS) is specified,
C or C++ makes
the parameter list available through a pair of macros; code them in
your main routine to determine which parameter list style your routine
receives: - __R1 of type
void * - __R1 contains the value that is in register 1 on entry into the main routine. It provides access to the parameters when they are passed according to the first two styles shown in Figure 1.
- __osplist of type
void ** __osplistacts as an array of pointers to parameters. It is derived from __R1 and provides access to the parameters when they are passed according to the third style shown in Figure 1. You must include the header filestdlib.hwhen using__osplist.
The third style is also supported for certain macros and functions
(for example, __pcblist and __csplist for
invokers IMS™ and Cross System
Product). __osplist is
a generalization of the more specialized __pcblist and __csplist macros;
it can be used in their place or in cases where they do not apply.
Figure 2 illustrates how these macros can be used to access items in the three alternate parameter arrangements.
Suitable casting and dereferencing are required when using these macros, as shown in Figure 3, according to the parameter passing style in use.