Pelles C forum

Pelles C => General discussions => Topic started by: czerny on January 20, 2013, 05:32:56 PM

Title: __FILE__ as WCHAR
Post by: czerny on January 20, 2013, 05:32:56 PM
Hallo,

is it possible to get __FILE__ as a WCHAR string?
Title: Re: __FILE__ as WCHAR
Post by: frankie on January 20, 2013, 05:41:51 PM
_T(__FILE__)
Title: Re: __FILE__ as WCHAR
Post by: czerny on January 20, 2013, 06:17:46 PM
I have to include <tchar.h> and define _UNICODE for this to work.

I had tryed to define

#define L(x) L##x

like _T is defined

but L(__FILE__) expands to L__FILE__

why?
Title: Re: __FILE__ as WCHAR
Post by: frankie on January 20, 2013, 07:30:42 PM
The former answer was completely erroneus. My wrong...  :-\

The problem is to make the preprocessor map the value as a string. for this you need a double expansion.
The following code should work

Code: [Select]
#define _L(x)  __L(x)
#define __L(x)  L##x

_L(__FILE__)
Title: Re: __FILE__ as WCHAR
Post by: czerny on January 20, 2013, 10:28:32 PM
for this you need a double expansion.
Ahh! thats the point!

Thank you!