public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problems with macros
@ 2002-12-11  6:07 Alexander.Schmid
  2002-12-11  6:21 ` John Love-Jensen
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander.Schmid @ 2002-12-11  6:07 UTC (permalink / raw)
  To: gcc-help

Hi everybody,

My system configuration: Suse Linux 8.1, gcc 3.2.

I´m porting some Windows stuff to Linux. To provide Unicode support, I use the
_T(x) macro from windows <tchar.h> , which actually puts an 'L' in front of the
text 'x'. The definition sounds like this:
#define _T(x)  L ## x

This works just fine when x is a string with quotationmarks or a character, like
_T("hello world") or _T('c'), but now I encountered a problem. When I call
_T(__FILE__), gcc seems just to interpret the _T macro and not the __FILE__
macro, so it leads to an error: "L__FILE__ not known", but the result should be
the actual file name in Unicode (The _T(__FILE__) works in Visual C++, so I
think it´s a gcc problem).

Can anybody tell me why this is and how I can get around this (perhaps a special
compiler flag?), or is there no hope for this problem?

Thanks in advance,
Alex





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Problems with macros
  2002-12-11  6:07 Problems with macros Alexander.Schmid
@ 2002-12-11  6:21 ` John Love-Jensen
  0 siblings, 0 replies; 2+ messages in thread
From: John Love-Jensen @ 2002-12-11  6:21 UTC (permalink / raw)
  To: Alexander.Schmid, gcc-help

Hi Alex,

I'm betting that Microsoft is the one that's not quite compliant.

It works if you have a two-stage macro:

g++ -E -c test.cpp
--- test.cpp ---
#define T(x) L ## x
#define R(x) T(x)
R(__FILE__)
--- end-of-file---

Voila!  Twiddle with the macro names as appropriate, and you shouldn't need
to change any of your existing source code.

--Eljay
(I hate macros.)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-12-11 14:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-11  6:07 Problems with macros Alexander.Schmid
2002-12-11  6:21 ` John Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).