As introduced here, the va_list
type is implemented as follows
typedef struct {
unsigned int gp_offset;
unsigned int fp_offset;
void *overflow_arg_area;
void *reg_save_area;
} va_list[1];
Can I directly modify the structure members of a va_list
variable?
va_list ap;
ap[0].gp_offset = 123; // I want something like this
ap->gp_offset = 123; // but none of these compile
When I try running this, I get these errors respectively
error: request for member 'gp_offset' in 'ap[0]', which is of non-class type '__va_list_tag'
error: request for member 'gp_offset' in '*(__va_list_tag*)(& ap)', which is of non-class type '__va_list_tag'
Why am I asking? I'm working with a large database, and I saw a somewhat hacky way to modify a va_list
variable as below. I wonder if this can be done without all this hassle.
va_list ap;
// Mimic GCC data structure
typedef struct {
unsigned int gp_offset;
unsigned int fp_offset;
void *overflow_arg_area;
void *reg_save_area;
}va_list2[1];
char* ap2 = (char*)≈ // same address as ap
va_list2* ap3 = (va_list2*)ap2; // same address as ap
(*a3)->gp_offset = 123; // Now this is allowed!