Using the GENCSRC Utility for Level Checking

Use the GENCSRC utility to retrieve externally described file information for use in a C/C++ program. The utility:
  • Creates a C/C++ header file which contains the type definition structure for the include file.
  • Supports creation of C/C++ include files.
Use the SLTFLD keyword to turn on level checking.
Note: For a list of options for the SLTFLD keyword, see The GENCSRC Utility and the #pragma mapinc Directive.
If you specify the keyword SLTFLD with value *LVLCHK on the GENCSRC command, in addition to generating the type _LVLCHK_T (array of structures), a variable of type _LVLCHK_T is also generated. The name of this variable of type _LVLCHK_T is based on some or all of the following:
  • File name specified for the OBJ keyword (see Figure 1)
  • Member name (see Figure 2)
  • Value of the TYPEDEFPFX keyword (see Figure 3)
  • Include name
    Note: In each of the following figures, the include name is actually the include file (that is, the SRCFILE/SRCMBR or SRCSTMF keywords).
In the case when SLTFLD(*LVLCHK) is specified with the default TYPEDEFPFX(*OBJ), the name of the level check structure is based on the file name as specified in the OBJ keyword and the include name (see Table 1). The GENCSRC command generates the level check structure named mylib_myfile_mymbr_lvlchk, as shown in the following examples:
Figure 1. Example of SLTFLD(*LVLCHK) with the Default TYPEDEFPFX(*OBJ)
GENCSRC OBJ('/QSYS.LIB/MYLIB.LIB/MYFILE.FILE') SRCFILE(INCLIB/H)   
SRCMBR(MYMBR) SLTFLD(*LVLCHK) TYPEDEFPFX(*OBJ)
or
GENCSRC OBJ('/QSYS.LIB/MYLIB.LIB/MYFILE.FILE')
SRCSTMF('incdir/mymbr.h) SLTFLD(*LVLCHK) TYPEDEFPFX(*OBJ)
/* ------------------------------------------------------- */  
// PHYSICAL FILE : MYLIB/MYFILE 
// FILE LAST CHANGE DATE : 2001/09/13
// RECORD FORMAT : FORMAT1
// FORMAT LEVEL IDENTIFIER : 38A624C5F3B51
/* ------------------------------------------------------- */

_LVLCHK_T  mylib_myfile_mymbr_lvlchk = {
     .
     .      
};
     .        
Note: The level check name depends on your source location (library, file, member).
In the case when SLTFLD(*LVLCHK) is specified with TYPEDEFPFX(*NONE), the name of the level check structure is based on the member name, and the commands in Figure 2 generate a level check structure named mymbr_lvlchk.
Figure 2. Example of SLTFLD(*LVLCHK) with the Default TYPEDEFPFX(*NONE)
GENCSRC OBJ('/QSYS.LIB/MYLIB.LIB/MYFILE.FILE') SRCFILE(INCLIB/H)   
SRCMBR(MYMBR) SLTFLD(*LVLCHK) TYPEDEFPFX(*NONE)
or
GENCSRC OBJ('/QSYS.LIB/MYLIB.LIB/MYFILE.FILE')   
SRCSTMF('incdir/mymbr.h) SLTFLD(*LVLCHK) TYPEDEFPFX(*NONE)
/* ------------------------------------------------------- */
 // PHYSICAL FILE : MYLIB/MYFILE
// FILE LAST CHANGE DATE : 2001/09/13 
// RECORD FORMAT : FORMAT1
// FORMAT LEVEL IDENTIFIER : 38A624C5F3B51
/* ------------------------------------------------------- */

_LVLCHK_T  mymbr_lvlchk = {
     .
     .
};
Note: The level check name depends on your source location (library, file, member).

In the case when SLTFLD(*LVLCHK) is specified with TYPEDEFPFX(prefix_name), the name of the level check structure is the prefix_name followed by the file name based on the OBJ keyword and the SRCFILE/SRCMBR or SRCSTMF keywords (the include file). The commands in Figure 3 give the level check structure named MYPREFIX_mylib_myfile_mymbr_lvlchk.

Figure 3. Example of SLTFLD(*LVLCHK) with the Default TYPEDEFPFX value *MYPREFIX
GENCSRC OBJ('/QSYS.LIB/MYLIB.LIB/MYFILE.FILE') SRCFILE(INCLIB/H)
SRCMBR(MYMBR) SLTFLD(*LVLCHK) TYPEDEFPFX(MYPREFIX)
or
GENCSRC OBJ('/QSYS.LIB/MYLIB.LIB/MYFILE.FILE')   
SRCSTMF('incdir/mymbr.h) SLTFLD(*LVLCHK) TYPEDEFPFX(MYPREFIX)
/* ------------------------------------------------------- */
 // PHYSICAL FILE : MYLIB/MYFILE
// FILE LAST CHANGE DATE : 2001/09/13 
// RECORD FORMAT : FORMAT1
// FORMAT LEVEL IDENTIFIER : 38A624C5F3B5
/* ------------------------------------------------------- */

_LVLCHK_T  MYPREFIX_mylib_myfile_mymbr_lvlchk = {
     .
     .
};
Note: The level check name depends on your source location (library, file, member).