C Error on 4d/25 TGX, irix 3.2.1

Robert Skinner robert at texas.esd.sgi.com
Sat Jul 14 03:33:21 AEST 1990


In article <8903 at potomac.ads.com>, baugh at 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 <stdio.h>
|> #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 at sgi.com

Send lawyers, guns and money. -- Warren Zevon



More information about the Comp.sys.sgi mailing list