Macro expansion help

Brandon Ibach bibach "at" infomansol.com
Wed, 15 Mar 2000 20:24:20 +0000


Quoting David Moreau <DavidM "at" learnlinc.com>:
> Could someone please "hand" generate the source code resulting when the
> following
> macro is expanded using DEFINE_HEXTILE(16)? I understand the "token passing"
> mechanism when ## is used (ie. ##bpp expands to 16) but what about bpp
> references
> not preceded by ##. And what about the second ## in
> COLOR_FROM_PIXEL##bpp##_ADDRESS(&bg)?
> Thanks for any insight.
> 
   I can't say for sure, but here's my take.  You don't need the ##
before the name (bpp, in this case) unless it is embedded in another
name.  However, if the embedded name is not at the end of the
surrounding name, then you need to follow it with another ##.
   So, if bpp is 16, then:
	PIXEL##bpp##_ADDRESS	=>	PIXEL16_ADDRESS
	CARD##bpp		=>	CARD16
	decode(bpp)		=>	decode(16)

   At least, I think that's right. :)  Let me know if you find
anything in there that doesn't fit.  If you're using GCC to compile,
check out the -E option, which stops after preprocessing and spits the
results out to standard output.

-Brandon :)

---------------------------------------------------------------------
To unsubscribe, send a message with the line: unsubscribe vnc-list
to majordomo "at" uk.research.att.com
See also: http://www.uk.research.att.com/vnc/intouch.html
---------------------------------------------------------------------