Re: `volatile' on local variable used outside of function
- From: Guillaume <"grsNOSPAM at NOTTHATmail dot com">
- Date: Tue, 27 Dec 2005 18:49:46 +0100
nickptar wrote:
/* 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 */
Do I then have to declare `i' as `volatile' to get the expected behavior?
Any decent compiler should detect that you're using a pointer to this local variable. I don't think you need to declare it "volatile".
If I'm wrong, I'd like to see a reasonable explanation. .
- References:
- `volatile' on local variable used outside of function
- From: nickptar
- `volatile' on local variable used outside of function
- Prev by Date: Re: `volatile' on local variable used outside of function
- Next by Date: Re: `volatile' on local variable used outside of function
- Previous by thread: Re: `volatile' on local variable used outside of function
- Next by thread: Re: `volatile' on local variable used outside of function
- Index(es):
Relevant Pages
|