Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Robbie Brown <dac@nomail.invalid> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | complex declarations |
| Date | 2014-03-04 20:18 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <lf5cdv$dll$1@dont-email.me> (permalink) |
I have the following code
/* declare signal as function (int, pointer to function (int) returning
void) returning pointer to function (int) returning void */
void (*signal(int, void (*)(int)) ) (int);
/* simplify things a bit using a typedef */
typedef void (*fptr)(int);
int main(void){
/* declare and define function that takes int and returns void */
void foobar(int x){
printf("%s%d\n", "x in foobar is ", x);
}
/* define signal using the typedef, compiles */
fptr signal(int x, fptr y){
return NULL;
}
/* What I'd like to do now is to replace the fptr typedef with the
pre typedef type if that makes sense.
Why? because it helps my understanding */
/* Here I can say, void y(), void (y)(), void (*y)(), void y(int),
void(y)(int) void (*y)(int) for the second arg and they all
compile */
fptr signal2(int x, void (*y)(int) ){
NULL;
}
/* finally I want to do something like
return a pointer to a function taking int and returning void
but I just can't figure out how to do it. I've tried
void (*)(int), void (int), (void (*) (int)) etc etc without
success */
/* can't get this to compile in any way */
//void (*x) (int) signal3(int x, void (*y)(int) ){
// return NULL;
//}
}
How do I code signal3 to completely get rid of my dependence on the
typedef. Once again, the only reason I want to do this is because I can
(hopefully)
Thanks
--
Rob - not floundering, fishing
Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread
complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-04 20:18 +0000
Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-04 15:49 -0500
Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-04 16:06 -0500
Re: complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-05 12:18 +0000
Re: complex declarations "BartC" <bc@freeuk.com> - 2014-03-05 12:56 +0000
Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-05 08:24 -0500
Re: complex declarations "BartC" <bc@freeuk.com> - 2014-03-05 16:26 +0000
Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-05 08:13 -0500
Re: complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-05 13:32 +0000
Re: complex declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-05 14:32 +0000
Re: complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-04 21:42 +0000
Re: complex declarations Keith Thompson <kst-u@mib.org> - 2014-03-04 14:04 -0800
Re: complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-05 09:22 +0000
Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-05 07:29 -0500
Re: complex declarations Keith Thompson <kst-u@mib.org> - 2014-03-05 08:38 -0800
Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-04 17:05 -0500
Re: complex declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-04 21:15 +0000
Re: complex declarations "BartC" <bc@freeuk.com> - 2014-03-04 21:38 +0000
Re: complex declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-04 23:27 +0000
Re: complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-04 21:59 +0000
Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-04 17:12 -0500
Re: complex declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-05 00:28 +0000
Re: complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-05 09:10 +0000
Re: complex declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-05 11:44 +0000
csiph-web