From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31492 invoked by alias); 7 Mar 2012 19:07:28 -0000 Received: (qmail 31484 invoked by uid 22791); 7 Mar 2012 19:07:27 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Mar 2012 19:07:09 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id C19881C6A2F; Wed, 7 Mar 2012 14:07:08 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id rvQ+2sDBVfcp; Wed, 7 Mar 2012 14:07:08 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 871651C69F1; Wed, 7 Mar 2012 14:07:08 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 4BF5C145615; Wed, 7 Mar 2012 11:07:03 -0800 (PST) Date: Wed, 07 Mar 2012 19:07:00 -0000 From: Joel Brobecker To: Jan Kratochvil Cc: gdb-patches@sourceware.org Subject: Re: [patch 2/2] typedef-checking for CU relative vs. absolute offsets [Re: RFC: problem with DW_OP_GNU_deref_type and dwarf's get_base_type callback] Message-ID: <20120307190703.GR2853@adacore.com> References: <20120305223429.GM2867@adacore.com> <20120307170940.GA22619@host2.jankratochvil.net> <20120307171249.GB22619@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120307171249.GB22619@host2.jankratochvil.net> User-Agent: Mutt/1.5.20 (2009-06-14) 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-03/txt/msg00237.txt.bz2 > This is not maintainable IMO in its current form. > > typedef struct { unsigned int co; } cu_offset; > typedef struct { unsigned int so; } sect_offset; [brainstorming] I like the idea of having distinct types. If we were using Ada, we would have been able to define distinct scalar types for our offsets, and the compiler would catch invalid uses. It's a bit more of a pain in C because the use of a struct makes it harder to use, but it's certainly better to catch these errors at compile time. I do find "co" and "so" a little too short and confusing, though. So, here is another suggestion: typedef struct { unsigned int val; } cu_offset; typedef struct { unsigned int val; } sect_offset; ? Would that be enough? Or maybe you really want different field names to make the writer aware of which offset he really has. In that case, perhaps field names that are a little more explicit? For instance: "rel_off" and "abs_off" (for "relative" vs "absolute")? -- Joel