From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1FyiMw-0003qK-1u for garchives@archives.gentoo.org; Fri, 07 Jul 2006 04:55:10 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.13.7/8.13.6) with SMTP id k674rje8029319; Fri, 7 Jul 2006 04:53:45 GMT Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.175]) by robin.gentoo.org (8.13.7/8.13.6) with ESMTP id k674mIu3012209 for ; Fri, 7 Jul 2006 04:48:18 GMT Received: by ug-out-1314.google.com with SMTP id j40so561846ugd for ; Thu, 06 Jul 2006 21:48:18 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=V9nHwbZXmG7SeFvUb1VjqQGEAMElSK2NTHU4A2aWvC/qdKWFpxpNcGX2uqzdVbZucRhvlDeN7e4pskSaev6lenuIzLNj0e/XqQ6aGpcpS6ydXFHvdejhIUS/YmRLOpWK4w37iqsPkWAksfhYx9epXrxdqWNNooDWiDmhIdX9sNE= Received: by 10.78.164.13 with SMTP id m13mr498880hue; Thu, 06 Jul 2006 21:48:18 -0700 (PDT) Received: by 10.78.20.11 with HTTP; Thu, 6 Jul 2006 21:48:17 -0700 (PDT) Message-ID: <7573e9640607062148n7edc5d55tfdd6f90ebdd77841@mail.gmail.com> Date: Thu, 6 Jul 2006 21:48:17 -0700 From: "Richard Fish" Sender: richard.j.fish@gmail.com To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] OT: get process name in c++ In-Reply-To: <1152246945.31828.3.camel@orpheus> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1151499883.17966.13.camel@orpheus> <200606281551.42342.petr.uzel@centrum.cz> <200606281601.07029.petr.uzel@centrum.cz> <1151542067.19231.0.camel@orpheus> <1152239843.31828.0.camel@orpheus> <7573e9640607061955y578b654djd96558656aa59fca@mail.gmail.com> <1152246945.31828.3.camel@orpheus> X-Google-Sender-Auth: 56d70f32d530c822 X-Archives-Salt: f6ad460c-1500-4442-b12b-b44c29ad9ecc X-Archives-Hash: f7c58441a336b811d2a46da5bd392e95 On 7/6/06, Iain Buchanan wrote: > yes I would, except that I'm editing a class which is inherited by a > multitude of programs, so the /proc way I only have to change one file, > whereas the argv[0] way I have to change every source file... No, that's the point of a global. Inheritance and all doesn't matter. You change main.c (2 lines): char* progname = 0; ... progname = argv[0]; main.h (1 line): extern char* progname; and the source file where you want to use it it (2 lines): #include "main.h" ... printf("progname is %s\n", progname); Your details might vary, for example if there is already a globals.h you could move the declaration from main.h to there, etc. But this really is the sane way of doing this... -Richard -- gentoo-user@gentoo.org mailing list