Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!cornell!uw-beaver!fluke!ssc-vax!dmg From: dmg@ssc-vax.UUCP (David Geary) Newsgroups: comp.lang.c Subject: Do you have to cast void pointers when dereferencing them? Keywords: (With ANSI C) Message-ID: <2414@ssc-vax.UUCP> Date: 13 Dec 88 18:52:38 GMT Organization: Boeing Aerospace Corp., Seattle WA Lines: 26 struct junk { int x,y; }; struct funk { float f,z; }; main() { struct junk J; struct funk F; void *p; J.x = 10, J.y = 20; F.f = 4.2, F.z = 5.6; p = &J, printf("JUNK: %d %d\n", p->x, p->y); p = &F, printf("FUNK: %f %f\n", p->f, p->z); } 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? -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ David Geary, Boeing Aerospace, ~ ~ #define Seattle RAIN ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~