From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26941 invoked by alias); 8 Nov 2012 18:12:20 -0000 Received: (qmail 26931 invoked by uid 22791); 8 Nov 2012 18:12:18 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-ob0-f169.google.com (HELO mail-ob0-f169.google.com) (209.85.214.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 08 Nov 2012 18:12:14 +0000 Received: by mail-ob0-f169.google.com with SMTP id va7so3507531obc.0 for ; Thu, 08 Nov 2012 10:12:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=epehxmXCLBWorMvkGfVqSOecpTl+w/pLu0yu0SRbYyc=; b=KiZPYIwqGgFVC4dxPL+LAh0kehqXQbIem2W7/y/bT0pnSt2RblggpNP/aw44J/ilhu MS7YQ4Jgg+OOjZEG6CdORnZLOP+osrMxn/Ih/S39o7qzHsS4QNmuLKoLuSkF1b1DzKXZ jPkw0ZwAcu9OU8Rkqx3Ms7kgVQzH5JyKAG0jB1Kq7jD5rOAUC3ZmseB0WAs+t/B8o5rP JfYvmsU/YCtAonhOTpoxSGOeWRHLcXHmRxAIvBCFoEy0TGjjRp5azvUm93naVZTx2fGw WvPO4Rhbveo2a2GvpMnlJ7eT8azCxQ09iIEtYmprju+YV3Ur4IHqhDPhqi1/rGvt5YDU df5Q== MIME-Version: 1.0 Received: by 10.182.172.74 with SMTP id ba10mr6395991obc.83.1352398333343; Thu, 08 Nov 2012 10:12:13 -0800 (PST) Received: by 10.76.71.201 with HTTP; Thu, 8 Nov 2012 10:12:13 -0800 (PST) In-Reply-To: <509BE290.4000104@redhat.com> References: <20121107201107.25258.47267.stgit@brno.lan> <509BE290.4000104@redhat.com> Date: Thu, 08 Nov 2012 18:12:00 -0000 Message-ID: Subject: Re: [PATCH] Always include defs.h first. From: Doug Evans To: Pedro Alves Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQmP4hJryKeeBJtKhG43repL62XGT8u87iEhZEl/NNvYI8G/flQdv9lsu/dlKKmzRpi3A1FqvAzF8QejNHfZQsb7fll2677PiKqikOvSj3oR4mCJhLJlC3FYLkNDn3whPwqMdN1o6caxiVmw6rLAekCjOJeKXKYGRywtUqooSl5+bEhXTRu65EPadVWSvm97YewkW2Lh6JYmLU63SMGHEP6y/1rTKA== X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-11/txt/msg00201.txt.bz2 On Thu, Nov 8, 2012 at 8:49 AM, Pedro Alves wrote: > On 11/08/2012 01:34 AM, Doug Evans wrote: >> On Wed, Nov 7, 2012 at 12:11 PM, Pedro Alves wrote: >>> defs.h should always be the first included header in a .c file. In >>> 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. >> >> fwiw, I like the idea of header files including what they themselves >> need, and not assuming the includer will do it for them, even for >> defs.h. >> It's something I'd like to see gdb move towards, but I'm not in a hurry. :-) > > Sorry, I hadn't imagined the change could be disagreeable. Otherwise, I'd > have waited. > > I'm also of the camp that advocates that header files should include what > they themselves need. OTOH, IMO, defs.h is special. > > - It's defs.h that includes config.h. Including config.h in headers > is bad practice. Comparing to gcc, I'd say defs.h is currently a > kind of a mix of system.h and coretypes.h, and whatnot. > - It's needed practically _everywhere_. > > Also: > > $ ls gdb/*.h | wc -l > 232 > > since not including defs.h in headers is the de facto standard on the code > base, where only 4 of those 232 had "#include defs.h" in them, and another > include was being introduced exactly because the corresponding .c file was in > error, I thought it best to just get rid of those 4 instances making the > codebase a little bit less inconsistent. Don't abort on my account - Consistency is Good. Another thing to consider: I'd like to move gdb to being more componentized (for lack of a better word). i.e., made up of application independent pieces. common/ is a minor step in this direction. Note that gdbserver doesn't have defs.h and lots of files in common/ do the #ifdef GDBSERVER #include "server.h" #else #include "defs.h" #endif dance. But again, don't abort on my account, Consistency Is Good, even if there's also a long term plan to do something different.