Array of pointers to functions

Jordan K. Hubbard jordan at greipa.UUCP
Tue Apr 23 17:26:20 AEST 1985


Ditto, I tried int *(fp_ret_ip[])() on my pyramid and it liked
it fine. I was too lazy to test it with an aggregate initialization
tho, So I can't in all honesty say that's the best way. Only thing I
can say is that there seems to be a definate difference in the
handling of * and [].. Some v7 compilers I've seen could give a hoot,
it's all the same to them. Others will consider the difference significant.

For instance:

On the last v7 compiler I used, these two statements were equally valid:

static char *foo = {
	"this",
	"that",
	"and the",
	"other thing"
};

static char foo[] = {
	"etc..",
	"and so",
	" forth"
};

However, a sysIII compiler on a 68K box would only grok the [] decl.
I guess a semantic difference would be that in the latter case you
were creating a temporarily unbounded array suitable for such an
initialization, whereas you were only allocating space for a pointer
before. But, as I say, it's semantic because you could also look at
the fact that the static array of pointers is going to be in some
compiler-reserved global area anyway & you are merely assigning the
address (I hesitated to say 'global section', shades of VMS!)..

This has been a puzzling question in the past & I have yet to run
into it on 4.2 because I haven't done much of that type of coding
on the pyramid yet.. I would welcome any flames/feedback or warnings
on the subject. Mail is probably best, I'll summarize if necessary.
(But HEY, if you want to start another discussion).
-- 
				Jordan K. Hubbard
				@ Genstar Rental Electronics.
				Palo Alto, CA.
				{sun, decwrl, dual}!twg!greipa!jordan

I'm your private hacker, hacking for money, any old keyboard will do..

					- Tina Turing



More information about the Comp.lang.c mailing list