Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ames!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!zardoz!dhw68k!arcturus!evil From: evil@arcturus.UUCP (Wade Guthrie) Newsgroups: comp.lang.c Subject: unions or void * to transmit "generic" pointers Keywords: unions, void, pointers Message-ID: <6003@arcturus> Date: 12 Sep 89 18:04:01 GMT Organization: Rockwell International, Anaheim, CA Lines: 44 I'm curious about whether it is okay to use a void * to transmit pointers between functions (when the func's agree on the type, but the at least one of the functions needs to be able to handle all sorts of DATA pointers) or whether it is more correct/portable to use unions of pointers. Specifically, I want to do something like: Routine() { sometype *stuff; /* a pointer to where to put the data */ . . . /* this routine needs to ask the user for some data, so it * will call a menu routine */ Menu( (void *) stuff, type); } Menu(point, type) void * point; int type; { . . . switch(type) { case SOMETYPE: *((sometype *) point) = /* something appropriate */ . . . } So, do I pass a union of pointers (seems pretty cumbersome) instead, or can I do the above? Wade Guthrie evil@arcturus.UUCP Rockwell International Anaheim, CA (Rockwell doesn't necessarily believe / stand by what I'm saying; how could they when *I* don't even know what I'm talking about???)