The GENCSRC Utility and the #pragma mapinc Directive

By using the Generate C/C++ Source (GENCSRC) utility to generate database header files, you can:
  • Extract data description specification (DDS) information
  • Create a header file with declarations for use in your programs

GENCSRC provides the means 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.

The #pragma mapinc directive uses the GENCSRC command to provide the opportunity to convert DDS files to include files directly.

To compare the GENCSRC utility and the #pragma mapinc directive:
  • GENCSRC can produce include files in IFS file systems or database file systems, while #pragma mapinc produces headers in database file systems only.
  • GENCSRC include files can be placed permanently anywhere, while #pragma mapinc writes generated include files into the QTEMP library.
The following table shows the comparison of #pragma mapinc options and the keywords for GENCSRC. For more information on any particular option, refer to the description of #pragma mapinc in the ILE C/C++ Compiler Reference.
Table 1. Comparison of GENCSRC Keywords and #pragma mapinc Options
GENCSRC Keyword #pragma mapinc option Description
SRCFILE member_name The name of the file that you reference on the #include directive in the source program. The output file is generated in the file system.
SRCMBR member_name The name of member with the header information. It follows the IBM® i naming conventions. The output file is generated in the file system.
OBJ file_name The path name of the object to map in QSYS file system.
SRCSTMF member_name The output file is generated in the IFS file system.
RCDFMT format_name Indicates the DDS record format to be included in your program. The default is *ALL.
SLTFLD options Restricted to a combination of the following values:
  • *INPUT
  • *OUTPUT
  • *BOTH (default)
  • *KEY
  • *INDICATOR
  • *LVLCHK1
  • *NULLFLDS
PKDDECFLD d or p *DECIMAL or *CHAR
STRUCTURE _P *PACKED or *NONPACKED
ONEBYTE 1BYTE_CHAR *ARRAY or *CHAR
UNIONDFN union_name *OBJ , NONE , or union_name
Note: *OBJ is the default and the default type definition union name is FILE_t and not LIBRARY_FILE_FMT_both_t as described in the #pragma mapinc directive
TYPEDEFPFX prefix_name *OBJ or *NONE1
Note:
  1. For more information, see Level Checking to Verify Descriptions.
Note: For information about DDS-to-C/C++ data type mapping, see the ILE C/C++ Compiler Reference.