443
edits
-
Changes
no edit summary
some of the features of HI-TECH C may be useful.
Although HI-TECH C allows the same structure or union
given in fig. 7.
struct tree_node { struct tree_node * t_left; struct tree_node * t_right; short t_operator; };
;Fig. 7. Member Naming
Because HI-TECH C insists on use of all intermediate
names when referencing a member nested inside several struc-turesstructures, some simple macro definitions can serve as a short-
hand. An example is given in fig. 8.
struct tree_node { short t_operator; union { struct tree_node * t_un_sub[2]; char * t_un_name; long t_un_val; } t_un; }; #define t_left t_un.t_un_sub[0] #define t_right t_un.t_un_sub[1] #define t_name t_un.t_un_name #define t_val t_un.t_un_val
;Fig. 8. Member Name Shorthand
This enables the variant components of the structure to
be referred to by short names, while guaranteeing portabil-ity portability and presenting a clean definition of the structure.
It is recommended that the type int be avoided wherever
possible, in preference to the types short or long. This is
because of the variable size of int, whereas short is com-monly commonly 16 bits and long 32 bits in most C implementations.
Some compilers permit a non-initialized global variable
with that variable.
This usage will be portable to virually virtually all other C
implementations.