I have a project where I want to have the two general types of structures:
struct A {
…
unsigned char *a;
…
};
struct B {
…
unsigned char b;
…
};
The general idea is that I want a member of struct A to be a pointer a member of struct A (without knowledge of the structure of B, other than B has a member unsigned char b).
My question is how do I initialize *a to the address of b? (and then properly reference b through *a within a function?)
I wish to initialize an instance of struct A as follows:
const struct A constinrom = { …, <something that extracts the addr of b> , …};
I wish to use struct A as follows (with no knowledge in anyfunction of struct B other than what is provided by struct A) :
void anyfunction (const struct A *name) {
(set variable c to equal the value in b)
(modify the value of c)
(set value in b equal the value in value of c)
}
Thank you,
Fyrdman
struct A {
…
unsigned char *a;
…
};
struct B {
…
unsigned char b;
…
};
The general idea is that I want a member of struct A to be a pointer a member of struct A (without knowledge of the structure of B, other than B has a member unsigned char b).
My question is how do I initialize *a to the address of b? (and then properly reference b through *a within a function?)
I wish to initialize an instance of struct A as follows:
const struct A constinrom = { …, <something that extracts the addr of b> , …};
I wish to use struct A as follows (with no knowledge in anyfunction of struct B other than what is provided by struct A) :
void anyfunction (const struct A *name) {
(set variable c to equal the value in b)
(modify the value of c)
(set value in b equal the value in value of c)
}
Thank you,
Fyrdman