Thursday, 8 August 2013

warning in macro that print a value

warning in macro that print a value

I have the following macro
I want to print a variable name then the value, so the macro will help
having the variable name to show then its value
the result of my example show
var = 1.234 printed on the screen.
#include <stdio.h>
#define str(s) #s
#define PRINTER(X) printf("% 12s = % f\n", str(X), X);
int main()
{
float var = 1.234f;
PRINTER(var);// <===== warning here
return EXIT_SUCCESS;
}
my question, if you try it, let me know if you get a warning within main,
and what it mean?? for me I get flag ` ' used with type `s'

No comments:

Post a Comment