Why is inner_LOAD_ATOM(buffer, ATOM_MAX)
converted to scanf("%" "ATOM_MAX" "s", x)
but the wrapped version isnt? I would expect ATOM_MAX(identifier) to be replaced by 10 before it is "passed" to inner_LOAD_ATOM
or LOAD_LINE
and making the wrapper useless. More elaborated answer why the wrapper is necessary would be very appreciated.
#include <stdio.h>
#define ATOM_MAX 10
#define inner_LOAD_ATOM(x, y) scanf("%" #y "s", x) /* inner part */
#define LOAD_ATOM(x, y) inner_LOAD_ATOM(x, y) /* wrapper of inner_LOAD_ATOM */
int main(void)
{
char buffer[ATOM_MAX] = {0, };
/* wrapped works fine */
LOAD_ATOM(buffer, ATOM_MAX);
/* [Warning] unknown conversion
type character 'A' in format [-Wformat=] */
inner_LOAD_ATOM(buffer, ATOM_MAX);
printf("%s\n", buffer);
return 0;
}