Re: typedef function with void parameters



Chris Dollin <chris.dollin@xxxxxx> writes:

So, which do you want -- a function taking a `void*` or a function taking
a `char*`? They're not compatible types. Pick one.

Oh, i thought that most pointer types could be converted/stored into
void pointer. I'm trying to wrap different function pointers into FUNC,
like,

,----
| int foo(char *p){}
| int bar(int *p){}
|
| typedef int (*FUNC)(void *);
|
| FUNC f1 = foo, f2 = bar;
`----

So, this is not allowed?

--
William

http://williamxu.net9.org
.



Relevant Pages

  • Types
    ... Operations are allowed between compatible types and not between any data whatsoever. ... Each type can have an associated pointer type: for int we have int pointer, for double we have double pointer, etc. ... Specific integer types ... If both specify repetition counts, ...
    (comp.lang.c)
  • Re: Passing execution to a memory address
    ... forbidden initialization of function pointer with void pointer ... int add1 ...
    (comp.lang.c)
  • Re: Is an unsigned integer big enough to store a void *?
    ... any type of int is the same size as a pointer. ... > If I use an unsigned integer to store a void pointer, ...
    (microsoft.public.vc.mfc)
  • Re: operator precedence
    ... > - typecast the void pointer into a type pointer ... But since ++ has precedence over the type cast ... I don't see why the result of (int *) wouldn't be an l-value. ...
    (comp.std.c)
  • Re: Definition of NULL
    ... > that yields a null pointer when evaluated. ... >>I've read a NULL pointer is zero (or zero typecast as a void pointer), ... (int *)0. ...
    (comp.lang.c)