EXTPROC({*CL|*CWIDEN|*CNOWIDEN| {*JAVA:class-name:}}name)
- EXTPROC(*CL:name)
- Specifies an external procedure that is written in ILE CL, or an RPG procedure to be called by ILE CL. Use *CL if your program uses return values with data types that CL handles differently from RPG. For example, use *CL when prototyping an RPG procedure that is to be called by a CL procedure when the return value is 1A.
- EXTPROC(*CWIDEN:name|*CNOWIDEN:name)
- Specifies an external procedure that is written in ILE C, or an RPG
procedure to be called by ILE C.
Use *CNOWIDEN or *CWIDEN if your program uses return values or parameters passed by value with data types that C handles differently from RPG. Use *CWIDEN or *CNOWIDEN when defining an RPG procedure that is to be called by C, or when defining the prototype for a C procedure, where the returned value or a parameter passed by value is 1A, 1G or 1C, 5U, 5I, or 4F.
Use *CNOWIDEN if the ILE C source contains
#pragma argument(procedure-name,nowiden)
for the procedure; otherwise, use *CWIDEN. - EXTPROC(*JAVA:class-name:name)
- Specifies a method that is written in Java™, or an RPG native method
to be called by Java. The first parameter is *JAVA. The second parameter is
a character constant containing the class of the method. The third parameter
is a character constant containing the method name. The special method name
*CONSTRUCTOR means that the method is a constructor; this method can be used
to instantiate a class (create a new class instance).
For more information about invoking Java procedures, see Rational Development Studio for i: ILE RPG Programmer's Guide.
- EXTPROC(name)
- Specifies an external procedure that is written in or to be called by RPG or COBOL. This format should also be used for a procedure that can be called by any of RPG, COBOL, C, or CL; in this case, you must ensure that the return value and the parameters do not have any of the problems listed above for *CL, *CWIDEN, and *CNOWIDEN.
The EXTPROC keyword indicates the external name of the procedure whose prototype is being defined. The name can be a character constant, or procedure pointer.
In a free-form definition, you can specify *DCLCASE as the name indicating that the external name is derived from the name of item being defined, in the same case as the name was specified. See Specifying *DCLCASE as the External Name.
When EXTPROC is specified, a bound call will be done.
If neither EXTPGM or EXTPROC is specified, then the compiler assumes that you are defining a procedure, and assigns it the external name found in positions 7-21.
If the name specified for EXTPROC (or the prototype or procedure name, if neither EXTPGM or EXTPROC is specified or if EXTPROC(*DCLCASE) is specified) starts with "CEE" or an underscore ('_'), the compiler will treat this as a system built-in. To avoid confusion with system provided APIs, you should not name your procedures starting with "CEE".
D SQLEnv PR EXTPROC('SQLAllocEnv')
If a procedure pointer is specified, it must be assigned a valid address before it is used in a call. It should point to a procedure whose return value and parameters are consistent with the prototype definition.
When a prototype is specified for a procedure, the EXTPROC keyword is specified for the prototype. Otherwise, the EXTPROC keyword is specified for the procedure interface. It is only necessary to explicitly specify a prototype when the procedure will be called from another RPG module. When the procedure is only called from within the same module, or when it is only called by non-RPG callers, the prototype can be implicitly derived from the procedure interface.
Figure 1 shows an example of the EXTPROC keyword with a procedure pointer as its parameter.