Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Do you have to cast void pointers when dereferencing them? Message-ID: <9186@smoke.BRL.MIL> Date: 15 Dec 88 00:58:50 GMT References: <2414@ssc-vax.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 16 In article <2414@ssc-vax.UUCP> dmg@ssc-vax.UUCP (David Geary) writes: > This runs just fine on my Sun, but gives me illegal >pointer WARNINGS. Under ANSI C, do I HAVE to cast >my void pointer, or not? Many older UNIX compilers will accept pointer to almost anything in the context p->member_name, if the member_name has an unambiguous structure offset. Indeed, really old UNIX kernels (around 6th Edition) relied heavily on this. It's not currently legal to use anything other than a pointer to a structure declared as having such a member_name in that context. This applies even more strongly for void*, which has only a small subset of permitted operations, definitely not including structure member reference. So, yes, write your code to say what you really mean.