Path: utzoo!utgpu!attcan!uunet!yale!wald-david From: wald-david@CS.YALE.EDU (david wald) Newsgroups: comp.lang.c Subject: Re: A cast pointer is NOT an lvalue!? (ANSI C) Keywords: X3J11, pointers, cast, lvalue Message-ID: <42234@yale-celray.yale.UUCP> Date: 4 Nov 88 19:21:37 GMT References: <479@midgard.mn.org> <10034@socslgw.csl.sony.JUNET> Sender: root@yale.UUCP Reply-To: wald-david@CS.YALE.EDU (david wald) Organization: Yale University Computer Science Dept, New Haven CT 06520-2158 Lines: 27 In article <10034@socslgw.csl.sony.JUNET> diamond@csl.sony.JUNET (Norman Diamond) writes: >In article <479@midgard.mn.org>, dal@midgard.mn.org (Dale Schumacher) writes: >> I used a pointer cast construct like this: >> >> value = *((long *) argp)++; > >If you wanted to increment argp by the length of a (long *), then you >have to do: > > value = *(long *) argp; > argp += (sizeof (long *)) / (sizeof argp); > >which cannot give a correct result if sizeof (long *) is not a >multiple of sizeof (int *). How about: value = *(long *)argp; argp = (argtype *)((char *)argp + sizeof(long *)); where argtype is the type of *argp? ============================================================================ David Wald wald-david@yale.UUCP waldave@yalevm.bitnet ============================================================================