From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13683 invoked by alias); 23 Feb 2002 17:56:46 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 13436 invoked from network); 23 Feb 2002 17:56:41 -0000 Received: from unknown (HELO localhost.redhat.com) (24.112.135.44) by sources.redhat.com with SMTP; 23 Feb 2002 17:56:41 -0000 Received: from cygnus.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 19F933D31; Sat, 23 Feb 2002 12:56:38 -0500 (EST) Message-ID: <3C77D7D5.3040502@cygnus.com> Date: Sat, 23 Feb 2002 09:56:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:0.9.8) Gecko/20020210 X-Accept-Language: en-us MIME-Version: 1.0 To: Jim Blandy Cc: Andrew Cagney , gdb@sources.redhat.com Subject: Re: Headers including other headers? References: <20020223172336.372F05E9DE@zwingli.cygnus.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-02/txt/msg00275.txt.bz2 The style guide says: http://sources.redhat.com/gdb/onlinedocs/gdbint_13.html#SEC111 > All `.c' files should include `defs.h' first. > > All `.c' files should explicitly include the headers for any declarations they refer to. They should not rely on files being included indirectly. > > With the exception of the global definitions supplied by `defs.h', a header file should explictily include the header declaring any typedefs et.al. it refers to. > > extern declarations should never appear in .c files. > > All include files should be wrapped in: > > > > #ifndef INCLUDE_FILE_NAME_H > #define INCLUDE_FILE_NAME_H > header body > #endif along with: http://sources.redhat.com/gdb/onlinedocs/gdbint_13.html#SEC107 > Declarations like `struct foo *' should be used in preference to declarations like `typedef struct foo { ... } *foo_ptr'. (Daniel J, note clause #1 :-). > Suppose a header file in gdb/ contains code cannot be compiled without > definitions from other header files --- it uses typedefs, structures > in a way that requires their size, etc. Is it more proper for the > header file to #include the other headers it requires itself, or > should it be the responsibility of the .c file #including it to also > bring in its prerequisites? > In hopes that this doesn't start a really long thread of unsatisfying > disagreements: I personally think that this is not a matter of huge > consequence either way, but it's nicer to have a consistent pattern, > so having someone simply establish any reasonable guideline is more > important than the actual details of that guideline. > > I'm not volunteering to convert our existing headers; I just want to > know what style is recommended for new header files. If you find you need to #include a system header file (since defs.h doesn't include it) then consider re-structuring the code so that GDB uses a host independant type - make the object opaque for instance. Andrew