N
nickptar
Let's say I have a situation like this:
/* begin example.c */
static int* ptr;
static void inner_fn(void)
{
*ptr = 1;
}
void outer_fn(void)
{
int i = 0;
ptr = &i;
inner_fn();
printf("%d\n", i);
}
/* end example.c */
in which a global pointer is set to point to a function-local variable
and then written to in another function. Do I then have to declare `i'
as `volatile' to get the expected behavior?
/* begin example.c */
static int* ptr;
static void inner_fn(void)
{
*ptr = 1;
}
void outer_fn(void)
{
int i = 0;
ptr = &i;
inner_fn();
printf("%d\n", i);
}
/* end example.c */
in which a global pointer is set to point to a function-local variable
and then written to in another function. Do I then have to declare `i'
as `volatile' to get the expected behavior?