Re: typedef function with void parameters
- From: Chris Dollin <chris.dollin@xxxxxx>
- Date: Thu, 13 Dec 2007 14:30:58 +0000
William Xu wrote:
This won't compile:
,----
| int foo(char *p)
| {}
|
| int main(int argc, char *argv[])
| {
| typedef int (*FUNC)(void *);
|
| FUNC f = foo;
| }
`----
The error is:
,----
| gcc -O2 /Users/william/studio/helloworlds/foo.cpp -lm -o foo
| /Users/william/studio/helloworlds/foo.cpp: In function 'int main(int, char**)':
| /Users/william/studio/helloworlds/foo.cpp:26: error: invalid conversion from 'int (*)(char*)' to 'int (*)(void*)'
`----
So, which do you want -- a function taking a `void*` or a function taking
a `char*`? They're not compatible types. Pick one.
--
Chris "can't fit a quart into a magnetic pot" Dollin
Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN
.
- Follow-Ups:
- Re: typedef function with void parameters
- From: William Xu
- Re: typedef function with void parameters
- References:
- typedef function with void parameters
- From: William Xu
- typedef function with void parameters
- Prev by Date: Re: replacement for 'pow()' function
- Next by Date: Re: Help me, a friend of mine wrote a program in C# and I wrote the same program in C..His is faster than mine on the same machine...How Come ?
- Previous by thread: typedef function with void parameters
- Next by thread: Re: typedef function with void parameters
- Index(es):
Relevant Pages
|