Path: utzoo!attcan!uunet!munnari.oz.au!uhccux!ames!sgi!shinobu!odin!texas.esd.sgi.com!robert From: robert@texas.esd.sgi.com (Robert Skinner) Newsgroups: comp.sys.sgi Subject: Re: C Error on 4d/25 TGX, irix 3.2.1 Message-ID: <10337@odin.corp.sgi.com> Date: 13 Jul 90 17:33:21 GMT References: <8903@potomac.ads.com> Sender: news@odin.corp.sgi.com Reply-To: robert@sgi.com Organization: Silicon Graphics Inc., Entry Systems Division Lines: 41 In article <8903@potomac.ads.com>, baugh@potomac.ads.com (Earl Baugh) writes: |> |> Ok, I'm totally confused here...In the following code segment, |> why do I get the error messages that follow....why undefined p1 & p2? |> I tried compiling the same source on a Sun (4.0.3) [though I had to |> change the prototype to the old style declaration] and two |> PC compilers and none of them had any problems, so why a problem |> with the iris? (I tried changing the prototype to an old style |> declaration and still had the same problem) |> |> If there is some "C" knowledge I'm missing here, I'd like to |> know where to find out about it..... |> |> ---------------------------------Code test.c ------------------------------- |> |> #include |> #define TYPETABLESIZE 255 |> |> int TypeHash(int code, void *p1, void *p2); |> |> int TypeHash (int code, void *p1, void *p2) |> { |> return (int) abs(((code * abs(((long)*p1+1)) * abs(((long)*p2+1))) % TYPETABLESIZE)) + 1; |> |> } |> I *think* its because p1 is a void*, when you say (long)*p1, you derefernce a void* which is undefined (fetch a void? whats a void?) then cast it to long. I think you want to cast it to a long*, then derefernce: *((long *)p1). (It shouldn't matter, but it would be nice if your cast matched what you pass: both ints or longs.) Robert Skinner robert@sgi.com Send lawyers, guns and money. -- Warren Zevon