[comp.lang.c] initializing arrays in structures

fujiirm@yendor.UUCP (09/08/87)

Suppose I was trying to declare/initialize the structure for the following data:

	pointer to function fna
	pointer to function fnb
	pointer to function fnc

	int	a1;
	int	a2;

	pointer to function tfn1
	pointer to function tfn2
	pointer to function tfn3
		.
		.
	pointer to function tfnx

Now, the number of functions should be considered variable until compile time.
The number functions shouldn't be hardcoded in, but rather resolved at compile
time.   (that is, if the functions were arrays, they would be like:
"int fn[] = { 0, 1, 2...}")
	

Now, my initial try was to do the following:

int fna(), fnb(), fnc(), tfn1(), tfn2(), tfn3()... tfnx();
struct {
	int	(*fns[])();
	int	a1;
	int	a2;
	int	(*alt[])();
} foo = {
	{ fna, fnb, fnc },
	0,
	2,
	{ tfn1, tfn2, tfn3.. tfnx }
};

BUZZ.  Doesn't work.  Doing some investigation, it seems that

int win[] = {0, 1}; 	is legal, but

sturct {
	int win[];
} lose = { {0,1} };	is not.


Now the question: is there any way of doing this and still keeping them
together in a structure (they all initialize independently fine)?



-- 
Roger Fujii - ACT, Reston, VA			Phone:		(703)471-9433
Internet: fujiirm@cml.rpi.edu
UUCP: ..!mimsy!{prometheus,hqda-ai}!yendor!fujiirm