Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!rpi!leah!bingvaxu!vu0310 From: vu0310@bingvaxu.cc.binghamton.edu (R. Kym Horsell) Newsgroups: comp.lang.c Subject: Re: Preprocessor macro to quote its argument Message-ID: <3891@bingvaxu.cc.binghamton.edu> Date: 25 Aug 90 18:03:41 GMT References: <1112@mti.mti.com> <1114@mti.mti.com> <1990Aug20.012839.3545@zoo.toronto.edu> <11517@ogicse.ogi.edu> <1990Aug21.175138.24633@zoo.toronto.edu> <21594@grebyn.com> Reply-To: vu0310@bingvaxu.cc.binghamton.edu.cc.binghamton.edu (R. Kym Horsell) Organization: SUNY Binghamton, NY Lines: 19 In article <21594@grebyn.com> ckp@grebyn.UUCP (Checkpoint Technologies) writes: \\\ >(This is just off the top of my head, so please be gentle...) > >Why can't this work? > >#define CTRL(ch) ((* #ch) - 64) > >It's ANSI only. The single # places it's arg in double quotes, making a >string, and the * returns the first byte of the string. This is fine (and I think has been pointed out recently on this newsgroup). A slight improvement may be #define CTRL(c) ((*#c)&037) 'though. -Kym Horsell