I can generate name for a function using an macro which is taken from C pre-processor defining for generated function names .
#define POSTFIX _ABC //_ABC should be mentioned only there
#define PROTOTYPENAME(symbol) symbol ## POSTFIX
#define PROTOTYPENAMED(sym) PROTOTYPENAME(sym)
int PROTOTYPENAMED(Function)(int a, int b, int c);
Above would result as
int Function_ABC(int a, int b, int c);
If I want to generate equivalent for #define ANOTHERFUNCTION_ABC WhatsThat()
I might want to write
#define PROTOTYPENAMED(ANOTHERFUNCTION) WhatsThat()
but this will redefine a PROTOTYPENAMED
macro. Is there a way to do it correctly without writing _ABC
everywhere?
PS. I am using Visual Studio 2013 and code should work in C and C++.
Edit: alk: this question contains more useful answer how to do this using another tools. You should not mark this question as dublicate.
Edit 2:
I was thinking about alternatives that do not need an external tools. Maybe it is not needed to declare it as macro? If we assume WhatsThat()
is returning int
, it is not forbidden to write int PROTOTYPENAMED(ANOTHERFUNCTION) = WhatsThat();
.