News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

__FILE__ as WCHAR

Started by czerny, January 20, 2013, 05:32:56 PM

Previous topic - Next topic

czerny

Hallo,

is it possible to get __FILE__ as a WCHAR string?

frankie

"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

czerny

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?

frankie

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

#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

Quote from: frankie on January 20, 2013, 07:30:42 PM
for this you need a double expansion.
Ahh! thats the point!

Thank you!