Re: Function pointer array as parameter to a function



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
.



Relevant Pages

  • Re: Copying an array slice (Was: Re: Difficulties with passing multi-dimensional arrays)
    ... > the pointer to array of unknown size. ... but it still compiles without a cast. ... unknown at compile time so nothing can be checked. ...
    (comp.lang.c)
  • Re: Warning on assigning a function-returning-a-pointer-to-arrays
    ... This declares pfunc as a function taking no arguments and returning ... int x, y; ... Presumably pfuncwill return a pointer to a single int, ... or the first of a sequence of "array 5 of int"s. ...
    (comp.lang.c)
  • Re: Newbie
    ... to talk about the int value 3 and the int value 4, ... It also lets you talk about pointer ... C has a special rule for array objects. ... to printf() is: ...
    (comp.lang.c)
  • Re: To cast or not to cast?
    ... I would cast it to byte array just in case. ... And make sure array size is OK before it's added to the SQL. ... > I'm certain that the biometricdata is not correctly inserted ... I know that the marshal copying from pointer to bytewent ok ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: union {unsigned char u[10]; ...}
    ... But character type is not a union. ... u.a is of type int. ... has to do so to make pointer equality work consistently). ... were a single-element array. ...
    (comp.lang.c)