From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8849 invoked by alias); 24 Jun 2010 19:57:08 -0000 Received: (qmail 8841 invoked by uid 22791); 24 Jun 2010 19:57:07 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Jun 2010 19:57:01 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5OJuxnS013320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Jun 2010 15:57:00 -0400 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5OJuvWb011989 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 24 Jun 2010 15:56:59 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o5OJuvpX020288 for ; Thu, 24 Jun 2010 21:56:57 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o5OJuu0w020287 for gdb@sourceware.org; Thu, 24 Jun 2010 21:56:56 +0200 Date: Thu, 24 Jun 2010 19:57:00 -0000 From: Jan Kratochvil To: gdb@sourceware.org Subject: gdbtypes.h #defined field accessors Message-ID: <20100624195656.GA19643@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-06/txt/msg00121.txt.bz2 Hi, I have a longterm question. gdbtypes.h contains definitions like: #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses #define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic Why the code does not use directly the right hand side? It would even have the same (in some cases shorter, in some cases longer) statements length: f (TYPE_N_BASECLASSES (type), TYPE_CPLUS_DYNAMIC (type); -> struct cplus_struct_type *cplus = TYPE_CPLUS_SPECIFIC (type); f (cplus->n_baseclasses, cplus->is_dynamic); I have only an idea to permit turning direct field into a getter such as is: #define TYPE_CPLUS_SPECIFIC(thistype) \ (!HAVE_CPLUS_STRUCT(thistype) \ ? (struct cplus_struct_type*)&cplus_struct_default \ : TYPE_RAW_CPLUS_SPECIFIC(thistype)) Coccinelle makes such later transformation automatic even without any macros. Should new fields still follow this paradigm? On Thu, 17 Jun 2010 04:31:57 +0200, Tom Tromey wrote: # It is customary to make new wrapper macros for new fields here. # I'm not sure that adds much benefit, but maybe just consistency is a # good enough reason. Thanks, Jan