Sign in to follow this  
jamesleighe

Token Pasting Operator Woes

Recommended Posts

Ok, so is this proper use of the token-pasting and stringizing operator? It seems I'm making a mistake somewhere...

[code]
#define LINK_TO_ENTITY_FACTORY(className) \
IEntity* Create##className () \
{ \
return new className; \
} \
\
EngineAPI ()->LearnEntity (#className, Create##className);
[/code]

Thanks as usual!

Share this post


Link to post
Share on other sites
iI don't know if you missed it or if the forum software just mangled your post, but multi-line macros must use \ characters at the end of each line to correctly continue after the break.

If that doesn't take care of it, you can configure the compiler to show you how it expanded the macro, which can help spot mistakes. The specifics depend on what particular compiler you're using.

Share this post


Link to post
Share on other sites
I never knew you could have VS spit out that kind of information!
Anyway, seems that it's working right and the problem must be somewhere else.

Thanks!

Share this post


Link to post
Share on other sites
Hidden
What does the signature of LearnEntity() look like? You seem to be passing it a class name as the first parameter, which would be invalid syntax.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this