Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion function pointer help needed
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Wayne Throop  
View profile  
 More options Jan 12 1987, 3:29 pm
Newsgroups: comp.lang.c
From: throopw@dg_rtp.UUCP (Wayne Throop)
Date: Mon, 12-Jan-87 15:29:51 EST
Local: Mon, Jan 12 1987 3:29 pm
Subject: Re: function pointer help needed

> j...@loral.UUCP (Jim Vaxkiller)
> I'm having a little problem with tables of pointers to functions.
> What I want to do is have several functions returning type void,
> The following code fragment illustrates my problem.
>       void err0() {}
>       int  err1() {}
>       static (*ptr_tbl[])() = { err0, err1 };
>       main() { (*ptr_tbl[0])(); }

You have declared ptr_tbl to be an array of pointers to functions
returning int, and err0 is a pointer to a void function.  You must use
casts or unions if you wish to have an array of pointers to functions of
more than one type.  Unions are probably the best method, though there
are problems with initializers for unions.  I don't see any portable way
to statically initialize an array of pointers to functions of differing
types.

--
You see, wire telegraph is a kind of very, very long cat.
You pull his tail in New York and his head is meowing in Los
Angeles.  Do you understand this?  And radio operates exactly
the same way:  you send signals here, they receive them there.
The only difference is that there is no cat.
                                --- Albert Einstein
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.