Click here to Skip to main content
15,888,221 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, I found this in a c++ code file and am curious to know what L ## means

C++
#define _XPLATSTR(x) L ## x


any ideas ?

What I have tried:

The usual googling and heavy drinking
Posted
Updated 11-Sep-16 1:21am

1 solution

See here: Preprocessor directives - C++ Tutorials[^] = search for "##" and you get:

Function macro definitions accept two special operators (# and ##) in the replacement sequence:
The operator #, followed by a parameter name, is replaced by a string literal that contains the argument passed (as if enclosed between double quotes):
C++
#define str(x) #x
cout << str(test);

This would be translated into:
C++
cout << "test";

The operator ## concatenates two arguments leaving no blank spaces between them:
C++
#define glue(a,b) a ## b
glue(c,out) << "test";

This would also be translated into:
C++
cout << "test";



I like the honesty though! :laugh:
 
Share this answer
 
v2
Comments
pkfox 11-Sep-16 8:16am    
Thanks Griff - nice example
OriginalGriff 11-Sep-16 8:18am    
You're welcome!
Richard MacCutchan 11-Sep-16 8:23am    
And the leading L makes it a Unicode string.
pkfox 11-Sep-16 8:51am    
Yes I knew that Richard it was the ## I didn't know :-) thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900