Message-Id: <199604051627.LAA11738@mail-e2b-service.gnn.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Fri, 05 Apr 1996 11:30:44 From: Jethro Wright To: djgpp AT delorie DOT com Subject: A Proper Cast for a Funtion Ptr.... Let me start of by saying: this isn't a compiler problem. Recently, I've hit a minor problem in a couple of different places, while working w/ library routines that need ptrs to functions. I can handle the obvious basics of passing an "appropriate" ptr. That is, a ptr to a function that exactly matches the indicated prototype. My problem is when I try to cast a ptr to a similar fn. For example: - this is the prototype for the fn I want to pass: void newfn( u_int s, void *, void * ) - this is the prototype for the fn I'm supposed to use: void oldfn( int s, void *, void * ) - I "thought" a cast like this would work: ((void) ((int), (void *), (void *))) newfn I've tried many different variations on the theme shown above, but w/o success. Usually, I get some sort of syntax error saying I have mis-matched parens. This isn't a compiler problem, bec I've encountered something similar usg different compilers (for different projs), but always wind up having to modify newfn, as a workaround, since I can't figure the correct way to cook up the desired cast. (BTW, I'm using a dumb editor to enter the cast shown above, so disregard any typing errors, since the mailer's editor doesn't do brace checking....) I've looked high and low, in source code and documentation, for examples, but I haven't seen anything that will help. (It's amazing that after earning my living writing C code for over ten years that something like this shud still hang me up.) Thanx in advance for any incoming answers. Jet ======================================================================= The continued survival of the human race, despite its own stupidity, is the strongest argument for the existence of a benevolent God. =======================================================================