Chapter Contents |
Previous |
Next |
The DSECT2C Utility |
This
section discusses the C
typedefs
and macro definitions that are generated
along with the structure definition.
Converting Assembler Language Types to C Language Types |
Assembler language supports a much larger variety of
types than does the C language. In addition, the best representation of a
specific assembler language type often depends on how the data are accessed
or modified. Therefore, conversion of assembler language types to C types
is not always straightforward. For this reason, DSECT2C constructs
typedefs
for some types. This allows a clearer definition of some types,
as well as making it easier for the programmer to choose a different C type
if necessary.
CL8
and
AL3
, shown in Sample DSECT2C Output File,
are examples of such
typedefs
.
Since the
typedef
name can only be declared once, DSECT2C
encloses each
typedef
in preprocessor statements to prevent multiple declarations
of the
typedef
name from occurring when two or more structures are included
in the same source file.
Using Symbol Macros |
As part of the conversion, DSECT2C generates a macro for each symbol in the DSECT. The replacement list for each macro is the member identifier associated with the symbol. Using these macros to refer to the member is usually easier (and more readable) than coding the member identifier itself. Sample DSECT2C Output File shows examples of such macros.
For example, given the structure
SAMPLECB
defined in
Sample DSECT2C Output File, you can
code the following:
#include "samplecb.h" int f(struct SAMPLECB *s) { return s->NUMBER; /* better than 's->_s0.number' */ }
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.