Re: FAQ 1.12--auto keyword



"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.
.



Relevant Pages

  • Re: FAQ 1.12--auto keyword
    ... it is necessary to forward declare a nested function (for ... It's gcc specific. ... Nested functions are not part of the language proper. ... Nested functions as a whole are a gcc extension, ...
    (comp.lang.c)
  • Re: FAQ 1.12--auto keyword
    ... it is necessary to forward declare a nested function (for ... gcc...I'm not sure if this is gcc specific or a language issue.) ... If gcc allows nested functions, ...
    (comp.lang.c)
  • Re: FAQ 1.12--auto keyword
    ... it is necessary to forward declare a nested function (for ... If gcc allows nested functions, ... if they want to invent a new language, ...
    (comp.lang.c)
  • Re: FAQ 1.12--auto keyword
    ... it is necessary to forward declare a nested function (for ... If gcc allows nested functions, ...
    (comp.lang.c)
  • Re: FAQ 1.12--auto keyword
    ... it is necessary to forward declare a nested function (for ... It's gcc specific. ... Nested functions are not part of the language proper. ...
    (comp.lang.c)