NO

Author Topic: __FILE__ as WCHAR  (Read 4636 times)

czerny

  • Guest
__FILE__ as WCHAR
« on: January 20, 2013, 05:32:56 pm »
Hallo,

is it possible to get __FILE__ as a WCHAR string?

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1875
Re: __FILE__ as WCHAR
« Reply #1 on: January 20, 2013, 05:41:51 pm »
_T(__FILE__)

czerny

  • Guest
Re: __FILE__ as WCHAR
« Reply #2 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?

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1875
Re: __FILE__ as WCHAR
« Reply #3 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__)

czerny

  • Guest
Re: __FILE__ as WCHAR
« Reply #4 on: January 20, 2013, 10:28:32 pm »
for this you need a double expansion.
Ahh! thats the point!

Thank you!