This is the mail archive of the 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]

GDB's #include file policy

(or lack there off :-)


Several recent patches have prompted the question of what guidelines, if
any, are there for GDB and its include files.

I think the short answer is that it hasn't had one and people have
simply done what was necessary to keep it building.  I'd like to tighten
this, just a little, so that people don't need to guess what goes where
so here goes...

Every GDB file looks like:

	#include "defs.h"
	#include "<random-bits>"
	#include "<more-random-bits>"
	#include "<yet-more-random-bits>"

the random bits are randomly ordered vis:

	#include "regcache.h"
	#include <system-header.h>
	#include "regcache.h"

trying to do otherwize would likely break things on some target.

"defs.h" contains all the basic declarations including key types
(LONGEST) and some very standard includes.  It also sucks in "config.h",
"bfd.h", "tm.h", "xm.h" and "nm.h".  For the moment it sucks in
"gdbarch.h" and a few other headers as well.  Header files should assume
that "defs.h" has already been included.

Outside of "defs.h", GDB header files should try to be self contained
(struct foo * VS typedef ...).  If a header file uses typedefs from
another GDB header (but not defs.h) then that should really be dragged
in.  This includes "tm.h" (until they are deleted).  This includes
functions in macros (until they are deleted also :-).

GDB has wrapper system headers (eg "gdb_wait.h").  Where added, they
should try to use POSIX or ISO-C as guidelines.  No real need to
introduce them until needed.

(Now the tricky bit) GDB headers should try to avoid sucking in system
header files.  The exceptions are "defs.h" and "gdb_*.h".  Probably also
"xm.h", "nm.h" and "terminal.h". I think the pratical reality is that
either "defs.h" will have already dragged the header file in (<stdio.h>)
or that a .C rather than a .H file should be doing the include.

"tm.h" and "xm.h" are definitly on the way out.
"nm.h" is probably heading the same way.

Hopefully this is sufficiently vague and waffly for no one to even


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