preprocessor/5240: Unicode L## doesn't work in all cases for macros
neil@gcc.gnu.org
neil@gcc.gnu.org
Wed Jan 2 01:40:00 GMT 2002
Synopsis: Unicode L## doesn't work in all cases for macros
State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Wed Jan 2 01:40:47 2002
State-Changed-Why:
Not a bug - GCC is correct.
The standard states that arguments are expanded, UNLESS the parameter is preceded by a # or ##, or followed by a ##. Your parameter is preceded by a ##.
I find it *very* hard to believe that other compilers get it wrong. In particular, Intel uses the EDG front end. Comeau also uses the EDG front end, and if you go to
http://www.comeaucomputing.com/tryitout/
and give the on-line compiler your input, with a command line of -E, the output you will get is
int main(int argc, char **argv)
{
...
CallToUnicodeFunction(LMyTestString);
...
}
which is what GCC is giving.
It is possible that all the compilers you list other than MSVC have a work-around for MSVC brokenness when on Windows, but I doubt it because even selecting WindowsNT on the Comeau home page doesn't affect the result. Maybe it requires an --enable-brokenness flag of some kind. *shrug*.
To get the result you want, you need to have an extra level of indirection so that the argument is expanded according to the rule I give above:
#define UNI_L2(string) L##string
#define UNI_L(string) UNI_L2(string)
#define MyTestString "Hello World!"
CallToUnicodeFunction(UNI_L(MyTestString));
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5240
More information about the Gcc-prs
mailing list