home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!europa.asd.contel.com!howland.reston.ans.net!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!stanford.edu!rutgers!news.cs.indiana.edu!noose.ecn.purdue.edu!mentor.cc.purdue.edu!daffnelr
- From: daffnelr@mentor.cc.purdue.edu (Throatwarbler Mangrove)
- Newsgroups: alt.hackers
- Subject: Stupid macro tricks...
- Message-ID: <C1DnqE.L3u@mentor.cc.purdue.edu>
- Date: 24 Jan 93 21:30:13 GMT
- Distribution: alt
- Organization: Me? Organized? Psha!
- Lines: 24
- Approved: my toe cheese
-
-
- Hey.. anyone out there got really
- ugly/complicated/elegant/interesting macros in any of their programs?
- As for the ugly part, it seems that bit manipulations can get that
- way very easily... Maybe we should have a contest for the ugliest
- macro that works for its intended purpose (that you've actually used
- in a program other than a test prog to see if it works..) Anyone got a
- good macro story?
-
- Obhack: the following macro.. Yeah, it's ugly, but it works.. x is a
- pointer to a struct flags is a field of various flags or'd together, y
- is a group of flags or'd together.. I want an expression that's true
- iff NONE of the flags set in y are set in x->flags, so I did:
-
- #define notplayer(x,y) !(~(x->flags | ~(y)) ^ (y))
-
- It gets called, for example, as notplayer(tmp, flags), where flags
- would be (flags = TRAD|HUSHED) and I want it to be 0 unless both bits
- are 0.
-
- And if you can think of a simpler way to do it, let me know..
- Laters..
-
- -Larry
-