This is the mail archive of the gdb-patches@sourceware.org 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: [PATCH] Always include defs.h first.


On 11/08/2012 04:11 AM, Pedro Alves wrote:
defs.h should always be the first included header in a .c file. In

I agree on this point.


turn, this means that a foo.h header should not need to include
defs.h, as the .c file always includes defs.h before including foo.h.


I am afraid I can't agree. If foo.h needs defs.h, it should include defs.h, rather than replying on foo.h's includer to include defs.h.


diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 05a030a..fbc2479 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -18,9 +18,10 @@
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see<http://www.gnu.org/licenses/>.  */

+#include "defs.h"
+
  #include <ctype.h>		/* XXX for isupper ().  */

-#include "defs.h"
  #include "frame.h"
  #include "inferior.h"
  #include "gdbcmd.h"

What is the include order of "defs.h" and system headers, such as <ctype.h> and <stdio.h>? When I learnt C programming some years ago, it was said system headers are included first, and then your own headers. This rule doesn't apply here?


--
Yao


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