Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!edcastle!refson From: refson@castle.ed.ac.uk (Keith Refson) Newsgroups: comp.std.c Subject: Making the preprocessor substitute a '#' Message-ID: <6261@castle.ed.ac.uk> Date: 11 Sep 90 17:05:47 GMT Sender: refson@castle.ed.ac.uk Reply-To: keith@earth.ox.ac.uk Organization: Oxford University Earth Sciences Dept. Lines: 24 Is there any way of defining a macro in an ANSI preprocessor which substitutes a '#' plus some other text. That is, I want to say #define FOO # pragma bar and have FOO replaced by the pragma. Now *I Know* that substituting pragmas is not standard and I don't care about that. It will be conditionally compiled for one machine only, on which it should work. The trouble is, of course that an ansi cpp interprets the # as a stringizing instruction. Is there any way of escaping it? I have found no reference to a backslash escape character in K&R 2. And though it works under the gnu cpp, it doesn't on my target machine. Can this be done? ---------------------------------------------------------------------------- | Keith Refson |ROYAL MAIL: | |-----------------------------------------| Department of Earth Sciences | | JANET : keith@uk.ac.ox.earth | Parks Road | | INTERNET: keith@earth.ox.ac.uk | Oxford OX1 3PR | | BITNET : keith%uk.ac.ox.earth@ukacrl | UK | | UUCP : K.Refson@ed.uucp |PHONE : +44 865 272026/272016 | | : keith%uk.ac.ox.earth@ukc.uucp |FAX : +44 865 272072 | ----------------------------------------------------------------------------