public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Engelhardt <jengelh@medozas.de>
To: Hiroki Kaminaga <kaminaga@sm.sony.co.jp>
Cc: eljay@adobe.com, gcc-help@gcc.gnu.org
Subject: Re: #line directive and -D option
Date: Wed, 17 Dec 2008 02:40:00 -0000	[thread overview]
Message-ID: <alpine.LNX.1.10.0812170335380.21696@fbirervta.pbzchgretzou.qr> (raw)
In-Reply-To: <20081217.105641.39158223.kaminaga@sm.sony.co.jp>


On Wednesday 2008-12-17 02:56, Hiroki Kaminaga wrote:
>Hi,
>
>From: "John (Eljay) Love-Jensen" <eljay@adobe.com>
>> 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 <stdio.h>
>int main(void)
>{
>  printf ("%s: .... \n", __FILE__);
   printf("%s: ...\n", HX_basename(__FILE__));
>  return 0;
>}

  reply	other threads:[~2008-12-17  2:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-16  6:11 Hiroki Kaminaga
2008-12-16 12:45 ` John (Eljay) Love-Jensen
2008-12-17  2:39   ` Hiroki Kaminaga
2008-12-17  2:40     ` Jan Engelhardt [this message]
2008-12-17  3:24     ` John (Eljay) Love-Jensen
2008-12-17  3:55       ` Jan Engelhardt
2008-12-17 17:47         ` Hiroki Kaminaga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.1.10.0812170335380.21696@fbirervta.pbzchgretzou.qr \
    --to=jengelh@medozas.de \
    --cc=eljay@adobe.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=kaminaga@sm.sony.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).