I had this crazy idea to use stdarg macros to copy data in a generic
fashion, regardless of type. However, I'm not sure it will work in part
due to the ANSI C default argument promotions and the fact that va_arg
requires a type to decide how far to advance to subsequent arguments. So,
essentially what I want in the variable argument function is something that
just assigns to a character type, and then copy a predefined number of
bytes to a target location (using memcpy or whatever).
Example:
void foo(int numargs, size_t size, ...)
Usage:
/*
* Must use in type due to default argument promotions
*
foo(3, sizeof(int), 'b', 'a', 'r');
or:
/*
* Bar is some defined type and bar1..4 are variables of that type
*
foo(4, sizeof(Bar), bar1, bar2, bar3, bar4);
Any suggestions?
Thanks,
-Clint
fashion, regardless of type. However, I'm not sure it will work in part
due to the ANSI C default argument promotions and the fact that va_arg
requires a type to decide how far to advance to subsequent arguments. So,
essentially what I want in the variable argument function is something that
just assigns to a character type, and then copy a predefined number of
bytes to a target location (using memcpy or whatever).
Example:
void foo(int numargs, size_t size, ...)
Usage:
/*
* Must use in type due to default argument promotions
*
foo(3, sizeof(int), 'b', 'a', 'r');
or:
/*
* Bar is some defined type and bar1..4 are variables of that type
*
foo(4, sizeof(Bar), bar1, bar2, bar3, bar4);
Any suggestions?
Thanks,
-Clint
Comment