enums, pcc & all that

aglew at ccvaxa.UUCP aglew at ccvaxa.UUCP
Thu Jun 19 23:51:00 AEST 1986


In this discussion of enums, I thought I'd mention a quick and pleasant
tool. I don't know if it has been mentioned before - hell, I might have
mentioned it! but it is useful:

I get tired of seeing

    #define MASK1   0x01
    #define MASK2   0x02
    #define MASK3   0x04
    ...
    #define MASKN   0x8000000

and even the corresponding enum is a pain.
So, a filter that expands

    enum_mask { MASK1, MASK2, MASK3 ... MASKN } 

into the appropriate series of #defines or enums is useful.

Of course, I realize that this violates the type rule; or, rather, I need to
declare a type which is a Cartesian product of the masks. And that really
should be a struct. Unfortunately, many compilers are too dumb to recognize
that lots of tiny bit field operations in a struct really can be done with
a single logical operation. Too bad.

Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew at gswd-vms



More information about the Comp.lang.c mailing list