Shouldn't this work?

Keith Rule keithr at zeus.UUCP
Fri Aug 17 06:50:31 AEST 1984


[bug food]


	The following program fragment demonstates a problem with
	"void". I wish to build a jump table to "void" functions,
	however this program fragment, which defines the jump table,
        doesn't compile. If I replace all the "void"s with "int"s the 
	fragment compiles without any problems.

 
	1	#include <stdio.h>
	2
	3	typedef struct Builtin {
	4		char *name;
	5		void (*func)();
	6	} BUILTIN;
	7
	8	extern void beep();
	9
	10	BUILTIN builtins[] = {
	11		{"beep",		beep},
	12		{(char *) NULL,		(void (*)()) NULL}
	13	};

	Output from lint. The C complier also produces the first 
	error message.

	tmp.c:
	tmp.c(11): operands of = have incompatible types
	tmp.c(11): illegal initialization
	builtins defined( tmp.c(10) ), but never used

	Would someone please tell me what I'm doing wrong. 
	I'm stumped.

	Thanks in Advance,

	Keith Rule

	tektronix!teklds!keithr



More information about the Comp.lang.c mailing list