Z
ziyan
Hello all,
I'm trying to write a macro that will let me access the fields of a
struct variable, given the field name as a parameter. I tried the
follwing which produces the desired result when run thru gnu cpp, but
it complains and stops.
#define ref(var,field) var. ## field
struct mystruct {
int i;
char c;
};
int main (void) {
struct mystruct aaa;
ref(aaa,i) = 1;
}
Any help is greatly appreciated.
___
Regards,
Ziyan Maraikar
Vrije Universiteit, Amsterdam.
I'm trying to write a macro that will let me access the fields of a
struct variable, given the field name as a parameter. I tried the
follwing which produces the desired result when run thru gnu cpp, but
it complains and stops.
#define ref(var,field) var. ## field
struct mystruct {
int i;
char c;
};
int main (void) {
struct mystruct aaa;
ref(aaa,i) = 1;
}
Any help is greatly appreciated.
___
Regards,
Ziyan Maraikar
Vrije Universiteit, Amsterdam.