B
Brian
// This macro is key
//
#define bitn(n) (1 << n)
// Define some stuff to "document" code without documenting anything
("self-documenting code")!
//
#define bitset8 uint8
#define bitset16 uint16
#define bitset32 uint32
#define bitset64 uint64
// Gotta love "close to the metal"!
//
#define chkbit(x, n) (((x) & bitn(n)) ne 0)
#define setbit(x, n) ((x) |= bitn(n))
#define clrbit(x, n) ((x) &= ~bitn(n))
#define tglbit(x, n) ((x) ^= bitn(n))
// WINDOW_THICK_BORDER|WINDOW_MINMAXBUTTONS anyone?
//
#define chkmask(x, m) (((x) & (m)) eq m)
#define setmask(x, m) ((x) |= (m))
#define clrmask(x, m) ((x) &= (~m))
#define tglmask(x, m) ((x) ^= (m))
// some uses may require the following
#define bitn64(n) (1ui64 << n)
**********
Aside, I use n-1 rather than n in the bitn macros, knowing that there is
potential for error there. I prefer, in this case, great semantics rather
than submission to the language.
//
#define bitn(n) (1 << n)
// Define some stuff to "document" code without documenting anything
("self-documenting code")!
//
#define bitset8 uint8
#define bitset16 uint16
#define bitset32 uint32
#define bitset64 uint64
// Gotta love "close to the metal"!
//
#define chkbit(x, n) (((x) & bitn(n)) ne 0)
#define setbit(x, n) ((x) |= bitn(n))
#define clrbit(x, n) ((x) &= ~bitn(n))
#define tglbit(x, n) ((x) ^= bitn(n))
// WINDOW_THICK_BORDER|WINDOW_MINMAXBUTTONS anyone?
//
#define chkmask(x, m) (((x) & (m)) eq m)
#define setmask(x, m) ((x) |= (m))
#define clrmask(x, m) ((x) &= (~m))
#define tglmask(x, m) ((x) ^= (m))
// some uses may require the following
#define bitn64(n) (1ui64 << n)
**********
Aside, I use n-1 rather than n in the bitn macros, knowing that there is
potential for error there. I prefer, in this case, great semantics rather
than submission to the language.