This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

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


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.


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