ILE C/C++ Programmer's Guide
To include multiple formats in a logical file, specify more than one
record format name or (*ALL) on the #pragma
mapinc directive. If you specify multiple formats, a header
description and type definition is created for each format. If you
specify a union- type-name, a union type definition is created.
C++ users must use the GENCSRC utility to create type definitions from an
external file.
C users can use either the GENCSRC utility or the #pragma mapinc
directive to create type definitions from an external file.
- Note:
- For more information on the differences between the GENCSRC utility and the
#pragma mapinc directive, see Appendix A, The GENCSRC Utility and the #pragma mapinc Directive.
The typedef union contains structure definitions created for each
format. Structure definitions that are created for key fields when the
key option is specified are not included in the union definition. The
name of the union definition is union-type-name_t. The name you
provide for the union-type-name is not folded to uppercase.
The following shows the type definitions created for a logical file with
two record formats with the BOTH and KEY options specified. A
typedef union with the tag buffer_t is also generated.
#pragma mapinc("pay","lib1/pay(fmt1 fmt2)","both key","","buffer","Pay")
#include "pay"
Figure 125. Structure Definition for Multiple Formats
/* --------------------------------------------------------*/
/* LOGICAL FILE: PAY */
/* FILE CREATION DATE: 93/09/01 */
/* RECORD FORMAT: FMT1 */
/* FORMAT LEVEL IDENTIFIER: 371E00A681EA7 */
/* --------------------------------------------------------*/
typedef struct {
.
.
.
}Pay_FMT1_both_t;
typedef struct {
.
.
.
}Pay_FMT1_key_t;
/* --------------------------------------------------------*/
/* LOGICAL FILE: PAY */
/* FILE CREATION DATE: 93/09/01 */
/* RECORD FORMAT: FMT2 */
/* FORMAT LEVEL IDENTIFIER: 371E00A681EA7 */
/* --------------------------------------------------------*/
typedef struct {
.
.
.
}Pay_FMT2_both_t;
typedef struct {
.
.
.
}Pay_FMT2_key_t;
typedef union {
Pay_FMT1_both_t; Pay_FMT1_both;
Pay_FMT2_both_t; Pay_FMT2_both;
}buffer_t;
|
- Note:
- A typedef union is not created for the key fields.
If you specify *ALL, or more than one record format on the
format-name parameter, structure definitions for multiple formats are
created.
If you specify multiple formats, and the input, or output option, one
structure is created for each format. The following shows the structure
definitions that are created when you include the following statements in your
program. The device file TESTLIB/FILE contains two record formats,
FMT1, and FMT2. Each record format has fields defined as OUTPUT in its
file description.
#pragma mapinc("example","testlib/file(fmt1 fmt2)","output","z","unionex")
#include "example"
Figure 126. Structure Definitions for a Device File
/* ------------------------------------------------------------------ */
/* DEVICE FILE: TESTLIB/FILE */
/* FILE CREATION DATE: 93/09/01 */
/* RECORD FORMAT: FMT1 */
/* FORMAT LEVEL IDENTIFIER: 371E00A681EA7 */
/* ------------------------------------------------------------------ */
typedef struct {
.
.
.
}TESTLIB_FILE_FMT1_o_t;
/* ------------------------------------------------------------------ */
/* DEVICE FILE: TESTLIB/FILE */
/* CREATION DATE: 93/09/01 */
/* RECORD FORMAT: FMT2 */
/* FORMAT LEVEL IDENTIFIER: 371E00A681EA8 */
/* ------------------------------------------------------------------ */
typedef struct {
.
.
.
}TESTLIB_FILE_FMT2_o_t;
typedef union {
TESTLIB_FILE_FMT1_o_t TESTLIB_FILE_FMT1_o;
TESTLIB_FILE_FMT2_o_t TESTLIB_FILE_FMT2_o;
}unionex_t;
|
When both are specified as an option, two structure definitions are created
for each format. The following shows the structure definitions created
when you include two formats, FMT1 and FMT2, for the device file
EXAMPLE/TEST and specify the both option:
#pragma mapinc("test","example/test(fmt1 fmt2)","both","z","unionex")
#include "test"
If all the fields are defined as BOTH and there are to be no indicators in
the typedef struct, only one typedef struct is generated for each format
specified. The following shows a separate typedef structure for input
and output fields.
Figure 127. Structure Definitions for BOTH Option
/* ------------------------------------------------------------------ */
/* DEVICE FILE: EXAMPLE/TEST */
/* CREATION DATE: 93/09/01 */
/* RECORD FORMAT: FMT1 */
/* FORMAT LEVEL IDENTIFIER: 371E00A681EA7 */
/* ------------------------------------------------------------------ */
typedef struct {
.
.
.
}EXAMPLE_TEST_FMT1_i_t;
typedef struct {
.
.
.
}EXAMPLE_TEST_FMT1_o_t;
/* ------------------------------------------------------------------ */
/* DEVICE FILE: EXAMPLE/TEST */
/* CREATION DATE: 93/09/01 */
/* RECORD FORMAT: FMT2 */
/* FORMAT LEVEL IDENTIFIER: 371E00A681EA8 */
/* ------------------------------------------------------------------ */
typedef struct {
.
.
.
}EXAMPLE_TEST_FMT2_i_t;
typedef struct {
.
.
.
}EXAMPLE_TEST_FMT2_o_t;
typedef union{
EXAMPLE_TEST_FMT1_i_t EXAMPLE_TEST_FMT1_i;
EXAMPLE_TEST_FMT1_o_t EXAMPLE_TEST_FMT1_o;
EXAMPLE_TEST_FMT2_i_t EXAMPLE_TEST_FMT2_i;
EXAMPLE_TEST_FMT2_o_t EXAMPLE_TEST_FMT2_o;
}unionex_t;
|
[ Top of Page | Previous Page | Next Page | Table of Contents ]
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.