Advertisement Jump to content
Sign in to follow this  
discman1028

[c++] Macro charizing operator #@ w/o Microsoft's help?

This topic is 3833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Basically, I want this:
#define TO_CHAR( a ) 'a'
...
TO_CHAR(x) ==> 'x' // btw, this gives us 'a'... :-(

(http://msdn.microsoft.com/en-us/library/91tt6dfs(VS.80).aspx) But in gcc. Let me know of any hacky way to do it, I can't think of one.

Share this post


Link to post
Share on other sites
Advertisement
That's pretty hacky. Not that the original task isn't hacky in itself :) Try

#define TO_CHAR(a) '##a##'

## is the token pasting operator.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
#define TO_CHAR(a) '##a##'



That ain't compiling. (Trivia: MS does have an alternate syntax for literals of the form 'abcd', which makes a word out of three or four characters... one of my tries looked something like your suggestion, with only four chars though instead of five, and compiled, but was, of course, incorrect.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!