Initializing the Runtime

If you are calling the runtime from a C main program, you must initialize the runtime prior to calling any COBOL programs from your C code. To do this, call the following routine:

acu_initv( argc, argv )
int     argc;
char    *argv[];

You pass this routine's arguments in a format identical to those passed to the C main function. The COBOL program's name is used during initialization to determine the default title of any GUI-based window, but the program itself is not loaded or executed. Arguments to the COBOL program are not used by initialization and may be omitted. If you omit the COBOL program name, initialization occurs using the default name of "cbl.out".

The acu_initv() function calls the user-supplied routines exam_args (passing argc and argv) and Startup (passing the name of the COBOL program). These routines are normally empty, but may be modified by you. They can be found in the "sub.c" file supplied with the runtime system.

Note: Since argv is an array of character pointers that may be needed after acu_initv() returns, keep argv in scope until you shut down the runtime. For more information, see acu_initv().


The following code might be used by a server routine that intends to use COBOL subroutines to perform various file operations. In this scenario, no screen operations are done from COBOL, so we want to inhibit ACUCOBOL-GT's default screen initialization. To do this, we must pass the "-b" command-line option. Because the program will perform no screen operations, we do not care about the default window title and, thus, do not need to pass a COBOL program name.

main( argc, argv )
int     argc;
char    *argv[];
     char     *initv[2];
     initv[0] = argv[0];
     initv[1] = "-b";
     acu_initv( 2, initv );
     /* other code follows */