例 - 型定義の翻訳

Header-to-copy ユーティリティが C ソース コード内の型定義を等価な COBOL COPY ファイル形式に翻訳する例を次に示します。

C のソース

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 コード

 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.

他の型定義は、相当する COBOL の形式定義を生成します。次に例を示します。

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

この型定義は、次の COBOL コードに変換されます。

 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.