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: Checking patch


 > 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.


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