preprocessor/5177: Problem with gcc-3.0.2 CPP and #define

Chris Adams cmadams@hiwaay.net
Sun Dec 23 16:16:00 GMT 2001


The following reply was made to PR preprocessor/5177; it has been noted by GNATS.

From: Chris Adams <cmadams@hiwaay.net>
To: Richard Henderson <rth@redhat.com>, neil@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
       gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: preprocessor/5177: Problem with gcc-3.0.2 CPP and #define
Date: Sun, 23 Dec 2001 18:14:14 -0600

 Once upon a time, Richard Henderson <rth@redhat.com> said:
 > On Sun, Dec 23, 2001 at 04:18:12PM -0000, neil@gcc.gnu.org wrote:
 > >     It is a bug in your package that it trips over the macro.
 > 
 > No, it's not his fault -- <sys/stat.h> contains something like
 > 
 > #if _DECC
 > #pragma prefix symbols with "_F64"
 > #else
 > #define stat(a,b,c)  _F64stat(a,b,c)
 > #endif
 
 Well, with only two arguments, but basically correct.  I didn't realize
 this until after I sent in the "bug".  I was under the (mistaken)
 impression that cpp shouldn't have been replacing the stat after the ->
 (and that the Compaq preprocessor was not).  After reading sys/stat.h
 some more (it is a little convoluted), I realized what was happening.
 
 > Basically, we'd have to do some extremely ugly fixincludery to
 > get this transformed to something that works properly wth gcc.
 
 I can't really see how it could be done other than to either support the
 DEC/Compaq "#pragma extern_prefix" extension (and detecting it and
 changing the #if around it) or generate an inline funcion like:
 
 static inline int stat(const char *x, struct stat *y) { return _F64_stat(x,y); }
 
 It seems like anything done with a macro would still trip up cpp.
 
 
 I did fix my case by changing:
 
     rc = db->stat(db, &dbi->dbi_stats, flags);
 
 into
 
     int (*stfunc) (DB *, void *, u_int32_t);
     stfunc = db->stat;
     rc = stfunc(db, &dbi->dbi_stats, flags);
 
 That works okay, so I'll pass it to the RPM folks to see if they'll
 accept it.  I'm surprised that this hasn't come up before with libdb3
 (maybe not many people use the ->stat call, at least on Tru64).
 
 Thanks for looking at this, and sorry to report a "not-a-bug".
 -- 
 Chris Adams <cmadams@hiwaay.net>
 Systems and Network Administrator - HiWAAY Internet Services
 I don't speak for anybody but myself - that's enough trouble.



More information about the Gcc-prs mailing list