tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* Embedding # in C preprocessor macros
@ 1998-02-09 16:23 Lew Randerson
  0 siblings, 0 replies; only message in thread
From: Lew Randerson @ 1998-02-09 16:23 UTC (permalink / raw)
  To: tru64-unix-managers

Re: Embedding # in C preprocessor macros

The following file

#define ATFB(X) mx#0
ATFB(a)

When run through /usr/ccs/lib/cpp on a Digital Unix v4.0B machine
gives:

 # operator should be followed by a macro argument name


What's the portable way of including # in macro bodies?

--------------------------------------------------------------------
This problem is caused by the addition of 'stringification' aka
  'stringization' of tokens which was added to ANSI C.  So something
  like:

    #define TEST(a,b) prinf( #a "<" #b "=%d\n", (a)<(b) )
    TEST(0,0xFFFF);

  will now under ANSI C become

    printf("0<0xFFFF=%d\n", (0)<(0xFFFF) );


In traditional C according to the non-Digital documentation I have: 

   * The character `#' has no special meaning within a macro
     definition in traditional C.

So my question then becomes 

   1) Is there a way to turn off stringification in cpp?
         or
   2) Is there a way to use # in a macro body even with 
      stringification turned on.

Thanks for any help.

--Lew
lranderson@Pppl.GOV

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-02-09 16:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-02-09 16:23 Embedding # in C preprocessor macros Lew Randerson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox