Hi, I'd like to know if this will do what I expect on all platforms (standard C99):
Of course what I expect is "arguments" not to be corrupted when it is passed to foo2. I suppose it is OK or else there is a serious problem with the name of this macro, but you never knowCode:void foo1(va_list arguments) { va_list arg_copy; va_copy(arg_copy,arguments); ... some code using va_arg on arg_copy and not on arguments ... va_end(arg_copy); } void foo2(va_list arguments) { va_list arg_copy; va_copy(arg_copy,arguments); ... some code using va_arg on arg_copy and not on arguments .... va_end(arg_copy); } void foo(int count, ...) { va_list arguments; va_start(arguments,count); foo1(arguments); foo2(arguments); va_end(arguments); }.
None of the exemples about va_copy I found treat this particular point, which made me wonder if there is a better way to do it. And considering that I didn't find much information about the various implementation of the va_list type and the va_arg macro, except that there are precisly various ones, that do not always get along with assignations and such (array of pointers of length 1 I think for example) I am rather unsure of this code.
Thanks.
EDIT: sorry about the incorrect code, shouldn't try to learn 3 different things at the same time.



LinkBack URL
About LinkBacks
.


