Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!husc6!linus!dartvax!eleazar.dartmouth.edu!earleh From: earleh@eleazar.dartmouth.edu (Earle R. Horton) Newsgroups: comp.sys.mac.programmer Subject: Re: Arrays of functions in THINK C Keywords: Why does this not work? Message-ID: <9651@dartvax.Dartmouth.EDU> Date: 3 Aug 88 03:05:31 GMT References: <2884@mit-amt.MEDIA.MIT.EDU> Sender: news@dartvax.Dartmouth.EDU Reply-To: earleh@eleazar.dartmouth.edu (Earle R. Horton) Organization: Dartmouth College, Hanover, NH Lines: 28 In article <2884@mit-amt.MEDIA.MIT.EDU> phil@mit-amt.MEDIA.MIT.EDU (Phil Sohn) writes: >typedef int (*GEN)(); > >int gen01(); > >GEN gensub[10]= {NULL, gen01} > >gensub[1](); <- compiler produces an error here > > > Anyone see what I am doing wrong? I believe it >is a bug in THINK C (including 3.0) because it works on >Vaxes, HPs, Suns, and in MPW. Try (* gensub[1])(); I don't think it's a bug in Think. I think Think is handling the situation properly. In the first form, you are attempting to call a pointer to a function. In the second form, you are calling the function referenced by the pointer. The reason the first form works on "Vaxes, HPs, Suns, and in MPW" is rather obvious: "What else could I possibly mean here?" K&R doesn't say anything about it. Anybody care to eleaborate about what ANSI says? Mr. Spock! This disk is damaged! Do you want to initialize it? Earle R. Horton. H.B. 8000, Dartmouth College, Hanover, NH 03755