help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Macros with G++


From: Michael Meier
Subject: Macros with G++
Date: Fri, 24 Sep 2004 00:50:52 -0400
User-agent: Opera7.23/Win32 M2 build 3227

Hi,

I'm not sure weather this is a compiler error or sonething different. The code:

#include <stdio.h>
#include <wchar.h>

//#define WIDE(x) L#x doesnt work
#define WIDE(x) L##x

int main( void )
{
  //wchar_t test = WIDE( Hello World ); doesnt work
   wchar_t* test = WIDE( "Hello World" );
   return 4;
}

The question is why the first approach doesn't work. g++ complains that L has not been defined. One hash should expand the variable and put it into quotes whereas two hashes just expand the variable. It works with two but not with one hash. Any explanation is welcome!





reply via email to

[Prev in Thread] Current Thread [Next in Thread]