home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / os2 / programm / 4513 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  1.9 KB

  1. Path: sparky!uunet!vnet.ibm.com
  2. From: ameline@vnet.ibm.com (Ian Ameline)
  3. Message-ID: <19920828.105606.807@almaden.ibm.com>
  4. Date: Fri, 28 Aug 92 13:54:32 EDT
  5. Subject: C Set/2 Question in malloc
  6. Newsgroups: comp.os.os2.programmer
  7. References: <1992Aug28.154836.12867@natinst.com>
  8. Organization: C-Set/2 Development, IBM Canada Lab.
  9. Disclaimer: This posting represents the poster's views, not those of IBM
  10. Lines: 60
  11.  
  12. In article <1992Aug28.154836.12867@natinst.com>,
  13. uma@natinst.com (Uma Arunkumar) writes:
  14. >
  15. >****************** C Set/2   QUESTION ************************
  16. >I am trying to compile a small program (to solve a problem in a huge program)
  17. >in C Set/2 version 1.00.
  18. >This program was taken from the C Set/2 Program Example given for malloc
  19. >using KWIKINF.
  20. >
  21. >***************************************************************
  22. >The program is given below:
  23. >
  24. >#include <stdio.h>
  25. >#include<malloc.h>
  26. >main()
  27. >{
  28. >   char str[50];
  29. >   long  *array;
  30. >   int i;
  31. >   for (i=0; i<50; i++)
  32. >       str[i]='m';
  33. >
  34. >  if  (( array= malloc(50 * sizeof(long)))!= NULL)
  35. >     for (i=0; i<50; i++)
  36. >       *array++=1;
  37. >
  38. >}
  39. >
  40. >*********************************************************
  41. >
  42. >When I compile giving the command
  43. >            icc /c /w3 /o+ sample.c
  44. >
  45. >       I get the following error messages:
  46. >
  47. >SAMPLE.C(12:15) : error EDC0117: The operation between these types is not valid.
  48. >SAMPLE.C(12:10) : informational EDC0140: Operand has type pointer to  signed long integer .
  49. >SAMPLE.C(12:17) : informational EDC0140: Operand has type signed integer .
  50. >
  51. >This program compiles without any error in C compiler in Sun.
  52. >
  53. >What is wrong in the above code?
  54. >
  55. >I WOULD HIGHLY APPRECIATE SOME HELP.
  56. >
  57. >Thanks in advance.
  58. >
  59. >My Email address is uma@natinst.com.
  60. >
  61. >uma.
  62. >
  63.  
  64.    The problem is malloc.h. It's there for backwards compatibility with
  65. MS and other pre-ANSI compilers. When using these headers, use the /Sm
  66. option, so we won't enforce the ANSI standard as strictly, or use
  67. stdlib.h.
  68.  
  69. Regards,
  70. Ian.
  71.  
  72.