Re: #line directive and -D option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 2008-12-17 02:56, Hiroki Kaminaga wrote:
>Hi,
>
>From: "John (Eljay) Love-Jensen" <eljay@xxxxxxxxx>
>> 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;
>}

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux