Thanks for your help tater. I guess it would help to provide more details and the oversimplification of the problem description was a bad idea, apologies.
Here is what really happens.
in myprogram.c
Code:
typedef struct mystruct{
int a;
.........
}mystruct_t;
mystruct_t newstruct;
int program_init () // Not main
{
......
myfunc(&newstruct.a); // updates the value of newstruct.a
}
anotherfunction()
{
calltosomething(newstruct.a); // passes null!
}
// several other functions called through program_init may set or use the value of a
so the point is that program_init sets the value of the elements in the structures (possibly more than one structure with more than one element) and anotherfunction uses this value for something.
and in tester.c I have
Code:
int main{
......
program_init()
......
.....
.....
if (something)
anotherfunction()
else
.......
// several other functions called through main may set or use the value of a
....
.....
}
I was hoping to be able to do this without passing around pointers to and fro, just being able to use a global pointer. tester.c is a about a thousand lines of code and myprogram.c is actually a set of C files that are a few thousand lines of code and it would make my life easier to not to include this additional field in several places.
Does this make sense?