From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6522 invoked by alias); 29 Jul 2009 08:45:46 -0000 Received: (qmail 6513 invoked by uid 22791); 29 Jul 2009 08:45:45 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 29 Jul 2009 08:45:39 +0000 Received: (qmail 20573 invoked from network); 29 Jul 2009 08:45:36 -0000 Received: from unknown (HELO wind.localnet) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 29 Jul 2009 08:45:36 -0000 From: Vladimir Prus To: gdb@sources.redhat.com Subject: Private data members Date: Wed, 29 Jul 2009 08:45:00 -0000 User-Agent: KMail/1.11.90 (Linux/2.6.24-24-generic; KDE/4.2.90; i686; svn-979530; 2009-06-10) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200907291245.32359.vladimir@codesourcery.com> 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: 2009-07/txt/msg00224.txt.bz2 I have run into a case when it's desirable that all modifications of a certain structure field in GDB codebase go via function that can enforce necessary invariants. Specifically, the ignore_count in struct breakpoint does not make any sense for tracepoint, therefore I want to introduce a function that will throw if non-zero ignore count is ever set for a tracepoint. At the moment, there are at least 3 places that directly assign a value to that field, and while I can convert them easily, nothing will prevent a direct assignment to appear in future. In C++, one would use 'private' visibility for that member, but it's not available in C. So, how about introducing a small convention -- that members with names ending in '_' are 'private' and should never be accessed by outside code. Another alternative is to modify the comment on ignore_count, but that is much more likely to be ignored. Comments? - Volodya