This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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: [RFC] missing #include in frame.h?


> My impression is that the right thing in these situations is normally
> to put an opaque declaration of the struct in question at the top of
> the header file:
> 
>   struct gdbarch;
>
> That way, header files can be included in any order without forcing
> them to include each other.

This makes sense. Thanks.

> But shouldn't all .c files inculde defs.h first?  (Indeed, that's what
> GDB Internals says.)  Which file were you compiling when you got this
> error?  Probably that file should be fixed to include defs.h before
> frame.h, instead of changing frame.h.

Ugh (excuse my French). If bla.h depends on defs.h, I think it is wrong
to ask all c files including bla.h to include defs.h first... But I come
from the Ada world, so maybe there is a good reason for this?

I dug a bit further, as my conclusions were a bit premature. Here is one
include stack example when this happens:

        In file included from breakpoint.h:25,
                         from gdbthread.h:29,
                         from config/nm-lynx.h:49,
                         from nm.h:24,
                         from defs.h:767,
                         from frame.c:23:

I checked frame.c, and it does include defs.h before frame.h. What
actually happens is that nm.h is indirectly including frame.h before
defs.h has included gdbarch.h... (nm.h = config/i386/nm-i386lynx.h,
which is equivalent to config/nm-lynx.h).

I think the best approach at this point is really to add the opaque
structure definition.

-- 
Joel


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