Jul 27, 2009 at 3:48pm UTC
lets say you have the form:
MY_MACRO(TemplateClass<x,y>)
the prepocessor sees the comma and thinks im trying to input "TemplateClass<x" and "y>" as parameters for MY_MACRO, but i just want one parameter "TemplateClass<x,y>"
how could i solve this?
Jul 27, 2009 at 4:21pm UTC
Don't use a macro. Use an inline function or just a function instead.
Jul 28, 2009 at 8:14pm UTC
theres no other way around it?
Jul 28, 2009 at 8:36pm UTC
Macros are evil for many reasons. You should refrain from using them. An inline function is likely the superior choice in this situation.
Although... I think you can encase macro parameters in parenthesis to prevent this from occuring:
MY_MACRO( (TemplateClass<x,y>) )
Not 100% on that, but it's worth a try.
But again. Ew. Use an inline function.
Jul 28, 2009 at 10:18pm UTC
Try the keyword typename, telling the compiler that TemplateClass<x,y> as a whole is a type, not anything else.
MY_MACRO( (typename TemplateClass<x,y>) )
Last edited on Jul 28, 2009 at 10:19pm UTC
Jul 28, 2009 at 11:56pm UTC
The parens that Disch suggested is the only thing that will help. It is a preprocessing issue.