From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7100 invoked by alias); 30 Aug 2010 11:49:14 -0000 Received: (qmail 7088 invoked by uid 22791); 30 Aug 2010 11:49:13 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out1.tiscali.nl (HELO smtp-out1.tiscali.nl) (195.241.79.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 Aug 2010 11:49:08 +0000 Received: from [212.123.169.34] (helo=[192.168.1.102]) by smtp-out1.tiscali.nl with esmtp (Exim) (envelope-from ) id 1Oq2rK-0005lA-8w; Mon, 30 Aug 2010 13:49:06 +0200 Subject: Re: [PATCH] tui-out: don't "inherit" redirect from CLI From: Paul Bolle To: Pedro Alves Cc: gdb-patches@sourceware.org In-Reply-To: <201008301229.12412.pedro@codesourcery.com> References: <1283160550.10594.1.camel@localhost.localdomain> <201008301229.12412.pedro@codesourcery.com> Content-Type: text/plain; charset="UTF-8" Date: Mon, 30 Aug 2010 11:49:00 -0000 Message-ID: <1283168942.10594.24.camel@localhost.localdomain> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit 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: 2010-08/txt/msg00509.txt.bz2 On Mon, 2010-08-30 at 12:29 +0100, Pedro Alves wrote: > That was the main reason that tui_ui_out_impl was made to inherit > cli_ui_out_impl in the first place. > See . Missed that one, obviously. (My excuse could be that the commit message doesn't seem to mention that reason.) > [...] tui_ui_out_data "inherits" cli_ui_out_data. > See: > > struct tui_ui_out_data > { > struct cli_ui_out_data base; > ^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > int line; > int start_of_line; > }; > typedef struct tui_ui_out_data tui_out_data; > > "base" is the first field of tui_ui_out_data, so you can > pass a pointer to a tui_ui_out_data to a function that expects > a cli_ui_out_data pointer. This is legal, and a common idiom on C, > as means to implementing "is-a" inheritance. Thanks for taking the time to explain this to me. Maybe next time I'll recognize the idiom. Paul