[comp.lang.c] "illegal pointer combination" problem

haozhou@acsu.buffalo.edu (Hao Zhou) (03/06/91)

This warning message keeps bothering me although my program runs
correctly. I am seeking an explaination to it.

In global:
struct pcb { 
  int no[QLEN]; 
  char *argv[QLEN][WRDNUM]; 
};

In main():
  struct pcb *tb; 
  getseg(&tb); 

In getseg(p):
  struct pcb **p; /* pointer to pcb pointer */
  *p = (struct pcb *) shmat(shmid,(char *)0,0);
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is the line which gives the warning error.

Any help on this will be highly appreciated.

Thanks in advance.   - Hao
-- 
Internet:haozhou@acsu.buffalo.edu BITNET:haozhou%acsu.buffalo.edu@UBVM.BITNET
UUCP: rutgers!ub!haozhou

cc100aa@prism.gatech.EDU (Ray Spalding) (03/06/91)

In article <63309@eerie.acsu.Buffalo.EDU> haozhou@acsu.buffalo.edu (Hao Zhou) writes:
>In getseg(p):
>  struct pcb **p; /* pointer to pcb pointer */
>  *p = (struct pcb *) shmat(shmid,(char *)0,0);
>  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>This is the line which gives the warning error.

In your post, you have not shown us the declaration for "shmat".

In appears that your compiler is warning you that converting the
return value type of "shmat" into a "struct pcp *" is "illegal".

Perhaps all you need is a proper declaration of "shmat" within the
scope of "getseg", e.g.:    struct pcp *shmat();

(If you have no declaration of "shmat()" in scope, it will be 
considered "int".  Theoretically, casts of ints to pointers is
OK, though not portable [except for constant 0].  My compiler
accepts this without comment, but I think a warning would be
acceptable, too.)
-- 
Ray Spalding, Technical Services, Office of Information Technology
Georgia Institute of Technology, Atlanta Georgia, 30332-0715
uucp:     ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!cc100aa
Internet: cc100aa@prism.gatech.edu