Article View: comp.os.os2.programmer
Article #1226C Set/2 Question in malloc
From: Ian Ameline
Date: Fri, 28 Aug 1992 17:54
Date: Fri, 28 Aug 1992 17:54
59 lines
2061 bytes
2061 bytes
In article <1992Aug28.154836.12867@natinst.com>,
uma@natinst.com (Uma Arunkumar) writes:
>
>****************** C Set/2 QUESTION ************************
>I am trying to compile a small program (to solve a problem in a huge program)
>in C Set/2 version 1.00.
>This program was taken from the C Set/2 Program Example given for malloc
>using KWIKINF.
>
>***************************************************************
>The program is given below:
>
>#include <stdio.h>
>#include<malloc.h>
>main()
>{
> char str[50];
> long *array;
> int i;
> for (i=0; i<50; i++)
> str[i]='m';
>
> if (( array= malloc(50 * sizeof(long)))!= NULL)
> for (i=0; i<50; i++)
> *array++=1;
>
>}
>
>*********************************************************
>
>When I compile giving the command
> icc /c /w3 /o+ sample.c
>
> I get the following error messages:
>
>SAMPLE.C(12:15) : error EDC0117: The operation between these types is not valid.
>SAMPLE.C(12:10) : informational EDC0140: Operand has type pointer to signed long integer .
>SAMPLE.C(12:17) : informational EDC0140: Operand has type signed integer .
>
>This program compiles without any error in C compiler in Sun.
>
>What is wrong in the above code?
>
>I WOULD HIGHLY APPRECIATE SOME HELP.
>
>Thanks in advance.
>
>My Email address is uma@natinst.com.
>
>uma.
>
The problem is malloc.h. It's there for backwards compatibility with
MS and other pre-ANSI compilers. When using these headers, use the /Sm
option, so we won't enforce the ANSI standard as strictly, or use
stdlib.h.
Regards,
Ian.
Technical Details
Message-ID:
<19920828.105606.807@almaden.ibm.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!vnet.ibm.comReferences:
<1992Aug28.154836.12867@natinst.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!vnet.ibm.com From: ameline@vnet.ibm.com (Ian Ameline) Message-ID: <19920828.105606.807@almaden.ibm.com> Date: Fri, 28 Aug 92 13:54:32 EDT Subject: C Set/2 Question in malloc Newsgroups: comp.os.os2.programmer References: <1992Aug28.154836.12867@natinst.com> Organization: C-Set/2 Development, IBM Canada Lab. Disclaimer: This posting represents the poster's views, not those of IBM Lines: 60