I really don’t have a clue how to give this question a good title – sorry for that.
Just to know what’s the goal of all this: pass a uint8_t variable pointer to bar() which does set it to 1 or 0, that I can check it’s state inside my main. I do need zbar(), it’s a thread and it does actually setting the value to 1 or 0
So I have somewhere:
struct foo_t {
...
uint8_t *state;
};
and in main I go with:
int main(void) {
uint8_t state = 0;
bar(&state);
while(1) {
if(state)
//do something here
}
}
and here we have somewhere else in another sourcefile.
void bar(uint8_t *state) {
struct foo_t *foo; //using malloc here - don't worry
foo->state = state;
zbar(foo);
}
void zbar(struct foo_t *arg) {
if(condition)
arg->state = 1;
else
arg->state = 0;
}
How to make this working? o0
zBar can actually access the arg struct, that’s not the problem at all.
Please don’t worry why I do it so strange, it’s used within threads etc.
I assume you meant
void bar(uint8_t* state)?It does not do what I think you intended. Again I assume you want the
statevariable inmainto be changed? If so tryI tihnk this is what you’re trying to do