This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Checking patch
- To: rth at cygnus dot com
- Subject: Re: Checking patch
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Sun, 10 May 1998 09:17:33 -0400 (EDT)
- Cc: egcs at cygnus dot com, law at cygnus dot com, martin at mira dot isdn dot cs dot tu-berlin dot de, wilson at cygnus dot com
> From: Richard Henderson <rth@dot.cygnus.com>
>
> On Fri, May 08, 1998 at 11:47:56AM -0400, Kaveh R. Ghazi wrote:
> > +#ifndef STRINGIFY
> > +# if defined(HAVE_CPP_STRINGIFY) || (defined(__GNUC__) && defined(__STDC__))
> > +# define STRINGIFY(STRING) #STRING
>
> If you are going to do something generic like this, make it
>
> #define STRINGIFY1(STRING) #STRING
> #define STRINGIFY(STRING) STRINGIFY1(STRING)
>
> as otherwise, by ISO rules,
>
> #define foo bar
> STRINGIFY(foo)
>
> will yield "foo" not "bar" as might be expected.
> r~
That's a good point, however I cannot get the !__STDC__ case to
work the same way. Eg, if I have the following code:
> #ifdef __STDC__
> #define STRINGIFY1(STRING) # STRING
> #else
> #define STRINGIFY1(STRING) "STRING"
> #endif
> #define STRINGIFY(STRING) STRINGIFY1(STRING)
>
> #define FOO hello world
>
> int main()
> {
> char * f = STRINGIFY(FOO);
> }
preprocessing this file with "gcc -E foo.c" yields:
> int main()
> {
> char * f = "hello world" ;
> }
whereas using "gcc -traditional -E foo.c" gives:
> int main()
> {
> char * f = "FOO";
> }
So I'm not sure we want to support this behavior unless we can
find a way to make KNRish compilers handle the same construct, else
stage1 may break on hosts like sunos4, hpux9, etc.
Do you have any ideas on how to solve this?
Thanks,
--Kaveh
--
Kaveh R. Ghazi Project Manager / Custom Development
ghazi@caip.rutgers.edu Icon CMT Corp.