enums, pcc & all that

Root Boy Jim rbj at icst-cmr
Tue Jun 24 07:39:53 AEST 1986


	I get tired of seeing
	
	    #define MASK1   0x01
	    #define MASK2   0x02
	    #define MASK3   0x04
	    ...
	    #define MASKN   0x8000000

Me too. That is like a #define ONE 1, #define TWO 2, etc. Why not
#define MASK(x) (1 << (x))	/* or x-1 if you like */
	
	and even the corresponding enum is a pain.

Or define the bit numbers as enums and generate masks from them.
enum bits { ox, ow, or, gx, gw, gr, ux, uw, ur, sticky, sgid, suid };
#define SUID MASK(suid);	/* danger! */

	So, a filter that expands
	
	    enum_mask { MASK1, MASK2, MASK3 ... MASKN } 
	
	into the appropriate series of #defines or enums is useful...

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


	(Root Boy) Jim Cottrell		<rbj at icst-cmr.arpa>
	...My vaseline is RUNNING...



More information about the Comp.lang.c mailing list