Re: FAQ 1.12--auto keyword
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Sun, 09 Apr 2006 15:45:54 GMT
"Bill Pursell" <bill.pursell@xxxxxxxxx> writes:
The faq (question 1.12) states that the keyword "auto" is completely
useless.
However, it is necessary to forward declare a nested function (for
gcc...I'm not sure if this is gcc specific or a language issue.)
In other words:
int
main(void)
{
AUTO int foo(void);
return 0;
int foo (void)
{
return 0;
}
}
is valid only if AUTO is "auto" and not empty. Is this a language
issue, or is allowing the forward declaration a gcc extension?
If a language issue, should the FAQ be modified?
Standard C doesn't allow nested function definitions.
gcc could have told you this:
% gcc -c -ansi -pedantic -DAUTO=auto tmp.c
tmp.c: In function `main':
tmp.c:4: warning: invalid storage class for function `foo'
tmp.c:8: warning: ISO C forbids nested functions
tmp.c:10: warning: ISO C90 forbids mixed declarations and code
(Same thing with "-std=c99", except that the last warning doesn't
show up.)
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- References:
- FAQ 1.12--auto keyword
- From: Bill Pursell
- FAQ 1.12--auto keyword
- Prev by Date: Re: FAQ 1.12--auto keyword
- Next by Date: Re: FAQ 1.12--auto keyword
- Previous by thread: Re: FAQ 1.12--auto keyword
- Next by thread: Re: FAQ 1.12--auto keyword
- Index(es):
Relevant Pages
|