Jump to content
  • Advertisement
Sign in to follow this  
vNistelrooy

Token-Pasting Operator (##)

This topic is 4842 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

How can I force VC++ 2005 to keep the spaces before the operator? for example: #define foo(a) void bar(const ##a) The preprocessor converts foo(1) to void bar(const1).

Share this post


Link to post
Share on other sites
Advertisement

#define foo(t) void bar(const t a)
foo(char); // results in bar(const char a)


The only reason you'd use the ## is when you *don't* want the space; if you need the space, there's no reason to use the operator.

Share this post


Link to post
Share on other sites
as stated above if you want to preserve space simply dont use ## just
#define FOO(x,y) x y
#define BAR(x,y) x##y

FOO(foo,bar);//will become: foo bar
BAR(foo,bar);//will become: foobar

you'll only need to use ## when you want to get rid of whitespace effectivly creating a new token from two earlier seen ones.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!