(void *) ? /* again */

Wm E Davidsen Jr davidsen at crdos1.crd.ge.COM
Wed Jan 24 00:22:12 AEST 1990


In article <21771 at unix.cis.pitt.edu> yahoo at unix.cis.pitt.edu (Kenneth L Moore) writes:

| Have you tried to coerce the type with 
|     
|        plong = (long *) malloc(sizeof(long)); 
| 
| and no declaration of malloc? This way you can use malloc for several
| different types of pointers in the same program.

  Sounds non-portable to me! If you don't declare malloc the compiler
assumes an int and generates code to convert an int into an address.
Since malloc doesn't return an int, in many implementations this will
not work properly.
-- 
bill davidsen	(davidsen at crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
            "Stupidity, like virtue, is its own reward" -me



More information about the Comp.lang.c mailing list