Example - Translating Type Definitions

The following example shows how the Header-to-copy utility translates type definitions in C source code to their equivalent COBOL copyfile form.

C source:

typedef char t_slab[12], cnt, c_list[], c_table[12][5];
typedef unsigned char BYTE, *BYTE_ptr;
typedef t_slab *t_slab_ptr;
typedef void _near _cdecl _export _dmsEVENT(short ent_type);
typedef _dmsEVENT *fptr;
typedef void (*XtActionProc)(
#if NeedFunctionPrototypes
  Widget  /* widget */,
  XEvent*  /* event */,
  String*  /* params */,
  Cardinal*  /* num_params */
#endif
);
typedef XtActionProc* XtBoundActions;

COBOL output:

 01  t-slab          is typedef pic x(12).
 01  cnt             is typedef usage char.
 01  c-list          is typedef usage data-pointer.
 01  c-table         is typedef.
     02  filler occurs 12   pic x(5).
 01  BYTE            is typedef usage uns-char.
 01  BYTE-ptr        is typedef usage data-pointer.
 01  t-slab-ptr      is typedef usage data-pointer.
 01  fptr            is typedef usage proc-pointer.
 01  XtActionProc    is typedef usage proc-pointer.
 01  XtBoundActions  is typedef usage data-pointer.

Other type definitions generate similar COBOL type definitions. For example:

typedef signed int I, AI[12], *PI, I_Table[12] [5];

produces the following COBOL code:

 01  I          is typedef usage int.
 01  AI         is typedef.
     02  filler occurs 12  usage int.
 01  PI         is typedef usage data-pointer.
 01  I-Table    is typedef.
     02  filler occurs 5.
         03  filler occurs 12 usage int.