0

I'm trying to create a macro that can be used to generically call CppUnitTestFramework's attributes metadata type. Since the calling convention for each test method is different because it uses the function's name in it I need to do something like this:

#define GetAttributes() CATNAME(CATNAME(CATNAME(__GetMethodMetadata,_),__func__),()))

With the hopes that when this macro is used like this:

...
void someFunction(){
    MethodAttributeMetadata* meta = GetAttributes();
    ...
}

Is processed like this:

...
void someFunction(){
    MethodAttributeMetadata* meta = __GetMethodMetadata_someFunction();
    ...
}

Extra info:

Compiler: Visual Studio Tools 2013 (v120)

Microsoft's macro page: https://msdn.microsoft.com/en-us/library/b0084kay.aspx

Is this something I can do?

Wes
  • 77
  • 7

1 Answers1

0

I've found the answer and it is no, you cannot do this. The problem with this approach was not the string concatenation but that func (or any form of it) cannot be used outside of a function, even through a layer of indirection.

Wes
  • 77
  • 7