`volatile' on local variable used outside of function
- From: "nickptar" <nickptar@xxxxxxxxx>
- Date: 27 Dec 2005 09:23:57 -0800
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?
.
- Follow-Ups:
- Re: `volatile' on local variable used outside of function
- From: Christian Bau
- Re: `volatile' on local variable used outside of function
- From: Guillaume
- Re: `volatile' on local variable used outside of function
- From: Walter Roberson
- Re: `volatile' on local variable used outside of function
- Prev by Date: newbie fscanf %[ conversions, multipliers
- Next by Date: Re: Watch window
- Previous by thread: newbie fscanf %[ conversions, multipliers
- Next by thread: Re: `volatile' on local variable used outside of function
- Index(es):
Relevant Pages
|
|