I thought I knew how MSVC 2010 treated multicharacter literals, until this:
int main(int argc, char* argv[])
{
int a = '\' ';
int b = '\'/ ';
int c = '\'/> ';
int d = '\'/>\x20'; // same as c supposedly
int e = 'ABC\x20';
printf("%X\n%X\n%X\n%X <-- what?\n%X\n", a,b,c,d,e);
return 0;
}
27202020
272F2020
272F3E20
20272F3E <-- what?
41424320
In the IDE's watch window if you type:
'\'/>\x20'
It prints out:
272F3E20
Which is what I would expect. So... what's going on here!?
I found this on the net, so I'm thinking it's a compiler bug. I guess it might not get fixed because it could break older code?
EDIT: I'm pretty satisfied that this is a quirk or a bug that isn't going to change. It only seems to occur when there is more than 1 escape sequence being used in the multicharacter literal.
Here is a workaround:
('\'/>' << 8) | '\n'