Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tdatirv!sarima From: sarima@tdatirv.UUCP (Stanley Friesen) Newsgroups: comp.lang.c Subject: Re: increment casted void pointer -- ANSI? Message-ID: <166@tdatirv.UUCP> Date: 11 Mar 91 17:06:17 GMT References: <4142@rwthinf.UUCP> <1991Mar8.165300.11692@zoo.toronto.edu> Reply-To: sarima@tdatirv.UUCP (Stanley Friesen) Organization: Teradata Corp., Irvine Lines: 22 In article <1991Mar8.165300.11692@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes: >In article <4142@rwthinf.UUCP> berg@marvin.e17.physik.tu-muenchen.de (Stephen R. van den Berg) writes: >> b=*++(char*)p; >> *--(char*)p=b; >> *++(char*)p=a; >There is no way to say "pretend this variable has a different type" in C. Not true, there *is* a way, Stephen just didn't use it. To pretend a variable has a different type utter the following magic incantations: b = *++ *(char **)&p; *-- *(char **)&p = b; *++ *(char **)&p = a; Now, I consider thsi hideous code, but it *does* allow nearly arbitrary type punning. [the *effect* is still non-portable] -- --------------- uunet!tdatirv!sarima (Stanley Friesen)