Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

casts in function-pointer arguments

Status
Not open for further replies.

DoraC

Programmer
May 7, 2002
98
US
Hi,

I'm a little perplexed about the following...

I've seen (and been able to do and work-with) casts along
the lines of
Code:
    char** ppcVar;
    void** ppvVar;
    
    ...

    ppvVar = ppcVar;
and all is well..

However, if I have function prototypes
Code:
    void function( char*, char** );
    void function2( void (*)( void*, void** ) );

and I try to do the following...
Code:
    function2( (void (*)( void*, void** )) function );
the compiler compains (of course I've defined the functions
elsewhere).

It works fine if I change void** to char**. Why can't I
cast the types in this fashion when they are arguments to
functions?

Thanks!
perplexed -
dora c.
 
Hi Dora C,
It seems that you have some compiler that is too strict on this. Well I tried this on a compiler and it worked fine after compilation. There were no warnings and nothing. Either you have turned on some more strict compilation options or your compiler is as such strict. Try with some other compiler and see.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top