home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / os2 / programm / 4508 < prev    next >
Encoding:
Text File  |  1992-08-29  |  1.2 KB  |  37 lines

  1. Path: sparky!uunet!stanford.edu!agate!ucbvax!TOROLAB6.VNET.IBM.COM!LANSCHE
  2. From: LANSCHE@TOROLAB6.VNET.IBM.COM ("Martin Lansche")
  3. Newsgroups: comp.os.os2.programmer
  4. Subject: RE:C Set/2 Question in malloc
  5. Message-ID: <9208281644.AA10538@ucbvax.Berkeley.EDU>
  6. Date: 28 Aug 92 16:44:05 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Lines: 27
  9.  
  10. Uma,
  11.    I saw your append in the comp.os.os2.programmer forum.  I believe that
  12. I can help.  C Set/2 is an ANSI compliant "C" compiler.  Sun's compiler
  13. is K&R "C". The ANSI definition for malloc is:
  14.  
  15. void * malloc(size_t);
  16.  
  17. While the K&R definition is:
  18.  
  19. char * malloc();
  20.  
  21. K&R compilers will not complain about implicit casts between potentially
  22. different sized pointers.  ANSI compilers do.  To explain the messages
  23.  
  24. - (12,15) gives the line number (12) and the column number (15)
  25. containing the operation that is illegal.
  26. - (12,10) says the the operand is at column 10
  27. - and (12,17) says the 2nd operand is at column 17
  28. All of this is supposed to help you determine exactly where the error is
  29. and to what the messages are referring.
  30.  
  31. To fix the problem, add a cast to the malloc, i.e.
  32.  
  33. array= (long *) malloc(50*sizeof(long);
  34.  
  35. Cheers,
  36. Martin Lansche  lansche@torolab6.vnet.ibm.com
  37.