This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: preprocessor/5240: Unicode L## doesn't work in all cases for macros
- From: neil at gcc dot gnu dot org
- To: dstarr at opera dot com, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: 2 Jan 2002 09:40:48 -0000
- Subject: Re: preprocessor/5240: Unicode L## doesn't work in all cases for macros
- Reply-to: neil at gcc dot gnu dot org, dstarr at opera dot com, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
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