|
 |
On 12 Sep 2000 05:17:32 -0400, Warp wrote:
>: (except that I'm surprised that this works inside another
>: function
>
> The C standard says that a function definition can be done inside another
>function. If done so, the scope of that function definition is only inside
>that other function
No, only function *declarations* inside other functions are permitted,
but not function *definitions*.
Thus:
int main(void) {
extern void foo(void);
void();
return 0;
}
is allowed, but:
int main(void) {
void foo(void) {
printf("hello\n");
}
void();
return 0;
}
is not.
>(it has a clear modular reason).
There is a good technical reason why it is not allowed. It makes
function pointers very difficult to implement and unintuitive to use.
Nevertheless, gcc implements it as an extension.
hp
--
_ | Peter J. Holzer | Nicht an Tueren mangelt es,
|_|_) | Sysadmin WSR | sondern an der Einrichtung (aka Content).
| | | hjp### [at] wsr ac at | -- Ale### [at] univie ac at
__/ | http://www.hjp.at/ | zum Thema Portale in at.linux
Post a reply to this message
|
 |