home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / alt / hackers / 1969 < prev    next >
Encoding:
Internet Message Format  |  1993-01-24  |  1.4 KB

  1. 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
  2. From: daffnelr@mentor.cc.purdue.edu (Throatwarbler Mangrove)
  3. Newsgroups: alt.hackers
  4. Subject: Stupid macro tricks...
  5. Message-ID: <C1DnqE.L3u@mentor.cc.purdue.edu>
  6. Date: 24 Jan 93 21:30:13 GMT
  7. Distribution: alt
  8. Organization: Me? Organized? Psha!
  9. Lines: 24
  10. Approved: my toe cheese
  11.  
  12.  
  13.   Hey.. anyone out there got really
  14. ugly/complicated/elegant/interesting macros in any of their programs?
  15. As for the ugly part, it seems that bit manipulations can get that
  16. way very easily... Maybe we should have a contest for the ugliest
  17. macro that works for its intended purpose (that you've actually used
  18. in a program other than a test prog to see if it works..) Anyone got a
  19. good macro story?
  20.  
  21. Obhack: the following macro.. Yeah, it's ugly, but it works.. x is a
  22. pointer to a struct flags is a field of various flags or'd together, y
  23. is a group of flags or'd together.. I want an expression that's true
  24. iff NONE of the flags set in y are set in x->flags, so I did:
  25.  
  26. #define notplayer(x,y)        !(~(x->flags | ~(y)) ^ (y))
  27.  
  28. It gets called, for example, as notplayer(tmp, flags), where flags
  29. would be (flags = TRAD|HUSHED) and I want it to be 0 unless both bits
  30. are 0.
  31.  
  32. And if you can think of a simpler way to do it, let me know..
  33. Laters..
  34.  
  35.    -Larry
  36.