This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [patch] beginnings of the macro rewrite


On Sat, Apr 22, 2000 at 10:33:07AM -0700, Zack Weinberg wrote:
> - macros are not disabled during their own expansions.  The practical
>   effect is that
> 
> #define EPERM EPERM

Yes, obviously people never did this with the traditional cpp.

>   will cause infinite recursion if you use EPERM anywhere.  There are
>   some perverse cases where it might actually be useful, though.
> 
> - macro arguments are expanded even inside strings and character
>   constants (but no effort is made to quote special characters).
> 
> - the # and ## (stringize and paste) operators are not available.
> 
> - comments are replaced by nothing _after_ arguments are substituted,
>   which means /**/ can be used to paste tokens.
> 
> - there is no special protection against accidental token paste; if
>   you write
> 
> #define foo(x) x+b
> foo(+);
> 
> you'll get ++b; instead of + +b;

A lot of the above is needed by people who invoke cpp to handle preprocessing
outside of the compiler.  For example, xrdb uses the preprocessor to process
ifdef's in the resources file (a feature I happen to use so I can adjust the
sizes of windows based on the screen size).  I believe X's xmkmf also uses the
standard preprocessor to create a Makefile from an Imakefile.  I know in the
past perl 4.036 used it too, but I don't know if modern perl's currently use
it.

-- 
Michael Meissner, Cygnus Solutions, a Red Hat company.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]