From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: strange warning Date: Sun, 15 Dec 1996 16:42:13 +0000 Organization: None Lines: 30 Distribution: world Message-ID: <1MJO0BAlpCtyEweT@talula.demon.co.uk> References: <58vhpj$ors AT nntp DOT novia DOT net> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Alaric Dailey writes: >context.c: In function `go_deep': >context.c:34 warning: function returns address of local variable > >the code it is complaining about is as follows - > >static char *go_deep(void) >/* > * Mark an area deep in the stack > */ >{ >int i; > > return((char*) &i); >} This is a valid warning, but one that you can probably ignore in this context. Normally returning a pointer to a local variable would be a mistake, since the variable 'i' exists on the stack, and as soon as go_deep() exits it will cease to exist (the stack space will be reused for something else, so the pointer will be meaningless). Judging from the comment, though, and from the fact that you say this came from a multitasking package, it looks as if it is the address, rather than the value, that is required, in which case the code is probably correct and you can just ignore the warning. /* * Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ * Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'. */