Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!ukc!harrier.ukc.ac.uk!mtr From: mtr@ukc.ac.uk (M.T.Russell) Newsgroups: comp.std.c Subject: Problem with prototypes and incomplete types Message-ID: <237@harrier.ukc.ac.uk> Date: 26 Feb 89 12:39:28 GMT Reply-To: mtr@ukc.ac.uk (M.T.Russell) Organization: Computing Lab, University of Kent at Canterbury, UK. Lines: 37 Consider the following code fragment: typedef struct object { int id; void (*destroy)(struct object *); /* line 3 */ } object; void destroy(object *obj) { /* destroy the object */ } void f(object *obj) { (*obj->destroy)(obj); /* line 13 */ } When I compile this with gcc 1.32 (the only ANSI C compiler I have access to) I get the following: obj.c:3: warning: parameter `obj' points to incomplete type obj.c: In function f: obj.c:13: incompatible types in argument passing Is gcc right to object to incomplete types in function prototypes? If so, is there any way to specify the type of a member of a structure which is a pointer to a function taking a pointer to the structure as an argument (sorry, I can't think of a better way to phrase this :-)). One workaround is to declare destroy as void (*destroy)(void *); but this loses type information. Mark Russell mtr@ukc.ac.uk