H2cpy is a utility program that converts C header files, such as those used when writing calls to the Win32 API, to their equivalent COBOL statements. The utility can convert:

C typedef to COBOL type definition
C function prototype to COBOL CALL prototype
#define to Level-78 item

The Header-to-copy utility also converts the various standard call conventions and methods of passing parameters to their COBOL equivalents.

The COBOL system then uses the entries in the copyfile to verify that the parameters used in a COBOL program conform to the definition in the original C-language header file. H2cpy simplifies COBOL programming when you are using libraries of routines whose call interfaces are provided as C-language header files, such as when calling the Win32 API.

The Header-to-copy utility converts all the specified C header files into one COBOL copyfile; you cannot convert C header files into separate COBOL copyfiles and then use these copyfiles in your program.

As a result of its conversion process, the Header-to-copy utility produces two COBOL files which you can include in your COBOL program using the COPY statement. The main .cpy file contains type definitions and literals; the subsidiary .ext file contains any external data declarations. As well as being essential when using C interfaces, you might also find H2cpy helpful when rewriting C programs in COBOL.

If you want to convert several header files, you can either list them on the command line, or you can create your own wrapper header file that contains an #include statement for each header file. You need to consider whether the header files require macros to be set to predefined values. C compilers often implicitly set some macros, but you must explicitly set any such macros; either on the command line, or in your wrapper header file.

If you commonly convert particular types of header files, such as, for example, the Windows API header files, then you will use similar groups of H2cpy options. You can save time by putting such options in a file, h2cpy.dir (see the -G H2cpy command line option for details.)

The Header-to-copy utility accepts any valid ANSI or ISO standard C source file. H2cpy might fail or generate incorrect COBOL code if it encounters invalid C.

You can invoke the Header-to-copy utility: