From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8638 invoked by alias); 1 Aug 2005 00:32:29 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 8599 invoked by uid 22791); 1 Aug 2005 00:32:25 -0000 Received: from smtp08.web.de (HELO smtp08.web.de) (217.72.192.226) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 01 Aug 2005 00:32:25 +0000 Received: from [85.212.29.115] (helo=[192.168.1.18]) by smtp08.web.de with esmtp (TLSv1:RC4-MD5:128) (WEB.DE 4.105 #297) id 1DzOEB-0001nm-00 for gcc-help@gcc.gnu.org; Mon, 01 Aug 2005 02:32:23 +0200 From: Gunther Piez To: gcc-help@gcc.gnu.org Subject: Re: Is is possible to use the name of a variable in the constructor? Date: Mon, 01 Aug 2005 00:32:00 -0000 User-Agent: KMail/1.8.1 References: <200508010155.53152.gpiez@web.de> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200508010232.22389.gpiez@web.de> X-Sender: gpiez@web.de X-SW-Source: 2005-08/txt/msg00001.txt.bz2 Am Montag, 1. August 2005 02:04 schrieb Ian Lance Taylor: > Gunther Piez writes: > > struct uniform { > > uniform() { > > cout << "A variable called " << __PRETTY_VARNAME__ << " was just > > instantinated (sp)" << endl; > > } > > }; > > Remember that in general uniform::uniform may be in different source > file, and may be compiled before the function which uses a variable of > type uniform. The only way this could be made to work would be to > have the compiler secretly pass the variable name into the function. > There is no infrastructure for noting which functions would require > the variable name, or for passing in the variable name. Ok, I understand the difference to __PRETTY_FUNCTION__ now :-) Maybe it is possible to use the debugging information somehow? At least the debugger usually knows the names of variables. Otherwise I have to use a constructor like uniform::uniform(const char*); and declare variables like uniform blah("blah"); which is ugly.