I need a macro which helps to output the given parameter’s name and value. It’s something like the following code.
#define AA "Hello"
#define BB "World"
#define PRINT(input_param) printf("input_param: %s\n", (input_param))
void main()
{
PRINT(AA);
PRINT(BB);
}
I’m expecting the result: AA: Hello\n BB: World\n
But obviously it’s not.
Anybody can correct me? Thanks.
You need to stringize the macro name with
#. This is howassert()works as well:It may be more clear if I wrote it like this: