I want to use sscanf
to parse a long string ..
The data to be parsed will be stored in a struct whose members are all of the type time_t
.
Unfortunately, there isn't any format string to mark a time_t
so I'm just going to typecast all time_t *
arguments as unsigned long long *
, and because its a very long string with lots of arguments, typecasting each argument one by one will only mess my editor screen ..
So, I created a macro to simplify this:
#define typecast(type, ...) (type) __VA_ARGS__
And I invoked it like this:
sscanf(string, PARSE_STRING,
typecast(unsigned long long *, /* my arguments */));
I though this would expand to:
sscanf(string, PARSE_STRING,
(unsigned long long *) /* arg1 */, (unsigned long long *) /* arg2 */, /* and so on */);
But after inspecting with gcc -E
, I found it expanded to this:
sscanf(string, PARSE_STRING,
(unsigned long long *) /* arg1 */, /* arg2 */, /* and so on */));
How can I achieve my desired expansion functionality using variadic functions ?
use boost