🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #191

Summary on cpp question from yesterday

#191
From: Ken Corey - Operator
Date: Wed, 29 Jul 1992 13:44
57 lines
1479 bytes
First I wanna say thanks to all that helped.  This has got to be the most
vocal group I've ever asked a question in...;)

Here's the summary about this question:

My question was about macro substitution.  The code I'd gotten the macros
that broke under GCC looked like:
  #define MUL(x,y)  ((x) << (y/**/Shift))
and was used like:
  MUL(this,that)
to get:
  ((this) << (that Shift));
where 'that Shift' should have been 'thatShift'.

There are two sugestions on how to fix this situation:

First, use the -traditional flag with GCC.  This turns off the /**/= ' '
rule, but also has other effects, and is not recommended because it changes
other rules also.

Second, instead of /**/, use ## as in:
  #define MUL(x,y)  ((x) << (y##Shift))
to get:
  ((this) << (thatShift));



Thanks to all for your quick response!

-Ken























-- 
Ken == kenc@sol.acs.unt.edu == kenc@vaxb.acs.unt.edu
 Real Programs don't use shared text.  Otherwise, how can they use
 functions for scratch space after they are finished calling them?
Technical Details
Message-ID: <1992Jul29.134422.6362@mercury.unt.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!mercury.unt.edu!sol!kenc

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!mercury.unt.edu!sol!kenc
From: kenc@sol.acs.unt.edu (Ken Corey - Operator)
Subject: Summary on cpp question from yesterday
Message-ID: <1992Jul29.134422.6362@mercury.unt.edu>
Sender: usenet@mercury.unt.edu (UNT USENet Adminstrator)
Organization: University of North Texas
Date: Wed, 29 Jul 1992 13:44:22 GMT
Lines: 57