Re: Function pointer array as parameter to a function
- From: Bart <bc@xxxxxxxxxx>
- Date: Tue, 20 May 2008 11:03:05 -0700 (PDT)
On May 20, 5:00 pm, vipps...@xxxxxxxxx wrote:
On May 20, 6:25 pm, Bart <b...@xxxxxxxxxx> wrote:
So what is the normal technique for a type specification to be
converted from declarative form to a cast?
The normal rule is just to write a declaration, remove the name and
the ; and enclose in ()s. Do you have an example where this is wrong?
Functions, you need to add an extra asterisk (*), ie
int foo(int);
int (*)(int)> Now that I try to find an example, it's not so easy!
Probably there was no actual error, apart from actual errors of syntax
and odd things like this:
int ((*((*(x(char)))[]))[]);
Why the redundant parenthesis?
That's equivalent to int (*(*x(char))[])[], and what the function
returns is a pointer to an incomplete array of pointers to incomplete
arrays of int.
int y;
This a type error (the type returns a function). But decl was quite
happy with the cast when written without the 'char':
(int ((*((*(()))[]))[]))y
But gave a syntax error on: (int ((*((*((char)))[]))[]))y
So just funny things with cdecl.
It's funny things with your code, nod cdecl.
I don't know. If you have cdecl to hand (and it's like mine) try this:
cdecl explain (int (*(*(char))[])[])x
Gives "syntax error"
Now take out the char to leave (), no parameters:
cdecl explain (int (*(*())[])[])x
Gives "cast x into function returning pointer to array of pointer to
array of int"
Why the difference between a function with 0 params and a function
with 1 param? Both are illegal surely?
--
Bartc
.
- Follow-Ups:
- Re: Function pointer array as parameter to a function
- From: Chris Torek
- Re: Function pointer array as parameter to a function
- References:
- Function pointer array as parameter to a function
- From: aruna . mysore
- Re: Function pointer array as parameter to a function
- From: Jens Thoms Toerring
- Re: Function pointer array as parameter to a function
- From: Bart
- Re: Function pointer array as parameter to a function
- From: Jens Thoms Toerring
- Re: Function pointer array as parameter to a function
- From: Bart
- Re: Function pointer array as parameter to a function
- From: Jens Thoms Toerring
- Re: Function pointer array as parameter to a function
- From: Bart
- Re: Function pointer array as parameter to a function
- From: Bart
- Re: Function pointer array as parameter to a function
- From: Ben Bacarisse
- Re: Function pointer array as parameter to a function
- From: Bart
- Re: Function pointer array as parameter to a function
- From: vippstar
- Function pointer array as parameter to a function
- Prev by Date: Re: Is this fully portable and/or smart?
- Next by Date: Re: Is this fully portable and/or smart?
- Previous by thread: Re: Function pointer array as parameter to a function
- Next by thread: Re: Function pointer array as parameter to a function
- Index(es):
Relevant Pages
|