Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!news From: tuna@athena.mit.edu (Kirk 'UhOh' Johnson) Newsgroups: comp.lang.c Subject: function declarator strangeness Summary: yep, i read K&R and the FAQ posting, but they didn't help Message-ID: <1990May30.173922.11825@athena.mit.edu> Date: 30 May 90 17:39:22 GMT Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 60 the following bits of grammar are culled from appendix A of K&R (1st ed.): function-declarator: /* page 204 */ declarator ( parameter-list_opt ) declarator: /* page 194 */ identifier ( declarator ) * declarator declarator ( ) declarator [ constant-expression_opt ] so a function "foo" returning a pointer to a function returning an int would be declared as: int (*foo())() { /* body of foo */ } imagine that i'd like "foo" to take one argument, arg, an integer. given the bits of grammar shown above, i would expect use: int (*foo())(arg) int arg; { /* body of foo */ } unfortunately, both pcc and gcc choke upon such a declaration. but if i rearrange things as int (*foo(arg))() int arg; { /* body of foo */ } both compilers generate code which seems to do the right thing, despite the fact that this declaration of "foo" doesn't seem to match the grammar shown in my copy of K&R (1st ed.). anybody have any helpful comments? how should the function-declarator grammar really read? if the problem is that K&R (1st ed.) is out of date, is there a better reference that isn't? although i will try to keep up with comp.lang.c to look for responses to my questions, i'd appreciate it if responses could also be e-mailed so i don't inadvertently miss them. thanks in advance for any help kirk -- ------------------------------------------------------------------------------- kirk johnson `Eat blue dogs tuna@masala.lcs.mit.edu and dig life.'