Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!ukc!eagle!icdoc!cam-cl!am From: am@cl.cam.ac.uk (Alan Mycroft) Newsgroups: comp.lang.c Subject: Re: How big is a (??? *) Message-ID: <724@jenny.cl.cam.ac.uk> Date: Sun, 7-Jun-87 09:22:45 EDT Article-I.D.: jenny.724 Posted: Sun Jun 7 09:22:45 1987 Date-Received: Sun, 21-Jun-87 15:01:52 EDT References: <1217@cullvax.UUCP> Reply-To: am@cl.cam.ac.uk (Alan Mycroft) Organization: U of Cambridge Comp Lab, UK Lines: 26 doug@edge.UUCP (Doug Pardee) writes: >> I want to do what is sometimes called "object-oriented" programming. >> Each source module consists of a bunch of routines which operate on a >> particular kind of object. Each instance of an object is described in >> detail by a struct which is malloc'ed by the object's "create" routine. >> [...] This seems to be something that ANSI (inter alia) haven't quite thought through concerning the possible size of pointers. ANSI say (3.5.2.2 Oct 86) that "an incomplete structure or union specifier ... may only be used when the size of an object of the specified type is not needed". Now, this has been used (reasonably in many senses) to argue that declaring an object as struct unknown *foo; is illegal since the compiler does not know the size of the pointer (since this may depend on the size of the object pointed to, consider machines where sizeof(char *) != sizeof(int *). However, this reading would also prohibit mutually recursive STRUCT's at all: struct ho { struct hum *chain; ... } struct hum { struct ho *chain; ... } Proposal: to allow this necessary feature, ANSI should declare that all pointers *to structs or unions* are of the same size, which is not necessarily the same sizeof(char *) or sizeof(int *).