NO

Author Topic: __FILE__ as WCHAR  (Read 6034 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: 2114
Re: __FILE__ as WCHAR
« Reply #1 on: January 20, 2013, 05:41:51 PM »
_T(__FILE__)
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

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: 2114
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__)
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

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!