nwatson@ENUXHA.EAS.ASU.EDU (Nathan F. Watson) (06/28/91)
I am using cfront (AT&T C++) on an SGI, and would like to use the '##' (concatenator) preprocessor 'statement' when defining a template. from my understanding, a file #define concat(a,b) a##b concat(asdf,jkl) should produce the file asdfjkl after preprocessing. I've tried variations of the above (e.g. putting spaces before, after the "##"). What do I need to do to allow this? Forgive me if the question is frequently asked, as I'm new to C++. --------------------------------------------------------------------- Nathan F. Watson Arizona State University nwatson@enuxha.eas.asu.edu Computer Science Department "Remember: No matter where you go, there you are." - Mr. B. Banzai
sinkwitz@ifi.unizh.ch (Rainer Sinkwitz) (06/28/91)
In article <9106272305.AA10159@enuxha.eas.asu.edu>, nwatson@ENUXHA.EAS.ASU.EDU (Nathan F. Watson) writes: > I am using cfront (AT&T C++) on an SGI, and would like to use the > '##' (concatenator) preprocessor 'statement' when defining a template. > from my understanding, a file > > #define concat(a,b) a##b > concat(asdf,jkl) > > should produce the file > > asdfjkl > > after preprocessing. I've tried variations of the above (e.g. > putting spaces before, after the "##"). What do I need to do > to allow this? Forgive me if the question is frequently asked, > as I'm new to C++. > > --------------------------------------------------------------------- > Nathan F. Watson Arizona State University > nwatson@enuxha.eas.asu.edu Computer Science Department > "Remember: No matter where you go, there you are." - Mr. B. Banzai Sometime ago a saw a thing like the following. It works with the ordinary C-Preprocessor and should also work with C++ : #define IDENT(x) x #define concat(a,b) IDENT(a)b Greetings... -- Rainer Sinkwitz | E-mail: sinkwitz@ifi.unizh.ch Dept. of Computer Science | sinkwitz%ifi.unizh.ch@relay.eu.net University of Zuerich | {backbone}!mcsun!unizh!sinkwitz
thant@horus.esd.sgi.com (Thant Tessman) (06/28/91)
I stole this from another program. I don't know enough to know why it works, but it does. #ifdef __ANSI_CPP__ #define CAT(a,b) a##b #else #define IDENT(a) a #define CAT(a,b) IDENT(a)b #endif Then I just use CAT(a,b) thant