From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8873 invoked by alias); 17 Dec 2008 02:39:25 -0000 Received: (qmail 8863 invoked by uid 22791); 17 Dec 2008 02:39:24 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_71 X-Spam-Check-By: sourceware.org Received: from sovereign.computergmbh.de (HELO sovereign.computergmbh.de) (85.214.69.204) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 17 Dec 2008 02:38:49 +0000 Received: by sovereign.computergmbh.de (Postfix, from userid 25121) id EF03C1811DF56; Wed, 17 Dec 2008 03:38:45 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by sovereign.computergmbh.de (Postfix) with ESMTP id E6F741C3DE709; Wed, 17 Dec 2008 03:38:45 +0100 (CET) Date: Wed, 17 Dec 2008 02:40:00 -0000 From: Jan Engelhardt To: Hiroki Kaminaga cc: eljay@adobe.com, gcc-help@gcc.gnu.org Subject: Re: #line directive and -D option In-Reply-To: <20081217.105641.39158223.kaminaga@sm.sony.co.jp> Message-ID: References: <20081216.151100.68033879.kaminaga@sm.sony.co.jp> <204DEA5423F3BF47A6EE88C4E2979EC66BDE084E1B@nambx04.corp.adobe.com> <20081217.105641.39158223.kaminaga@sm.sony.co.jp> User-Agent: Alpine 1.10 (LNX 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-12/txt/msg00191.txt.bz2 On Wednesday 2008-12-17 02:56, Hiroki Kaminaga wrote: >Hi, > >From: "John (Eljay) Love-Jensen" >> Hi Hiroki, >> >> Worked on my machine. >... >> Depending on your shell, you may need to escape the quotes, such as one of these two ways: >> -D MYNAME=\"macrotest\" >> -D MYNAME='"macrotest"' > >Ah, above worked, thank you! > >By the way, is there any method to strip strings prefix passed to >__FILE__ macro? If .c file is specified by abosolute path, __FILE__ >also prints absolute path: Well use a function that returns the basename. Something like /* from libHX-1.28/src/string.c */ EXPORT_SYMBOL char *HX_basename(const char *s) { const char *p; if ((p = strrchr(s, '/')) != NULL) return const_cast1(char *, p + 1); return const_cast1(char *, s); } and >$ cat macro-test.c >#include >int main(void) >{ > printf ("%s: .... \n", __FILE__); printf("%s: ...\n", HX_basename(__FILE__)); > return 0; >}