Using Operational Descriptors to Pass Parameters of Unknown Data Type

To pass a parameter to a procedure even though the data type is not precisely known to the called procedure you can use operational descriptors. Operational descriptors provide descriptive information to the called procedure regarding the form of the argument. This information allows the procedure to properly interpret the passed parameter. Use operational descriptors only when they are expected by the called procedure.
Note: For more information on operational descriptors, see:
  • ILE Concepts
  • ILE C/C++ Compiler Reference

The C++ compiler supports operational descriptors for describing null-terminated strings. A character string in C++ is defined by: char string_name[n], char * string_name, or string-literal.

C++ defines a string as a contiguous sequence of characters terminated by and including the first null character. In another language, a string may be defined as consisting of a length specifier and a character sequence. When passing a string from a C++ function to a function written in another language, an operational descriptor can be provided with the argument to allow the called function to determine the length and type of the string being passed.

To use operational descriptors, you specify a #pragma descriptor directive in your source to identify functions whose arguments have operational descriptors. Operational descriptors are then built by the calling procedure and passed as hidden arguments to the called procedure. For the syntax, see the ILE C/C++ Compiler Reference.

The following examples illustrates the use of operational descriptors in ILE C/C++. They show:
  • The #pragma descriptor for func1() with a #pragma descriptor directive for the function in a header file oper_desc.h. See Figure 1.
  • An ILE C program that calls func1(). See Figure 1.
  • The ILE C source code of func1() that contains an ILE API that is used to get information from the operational descriptor. See Figure 1.