home *** CD-ROM | disk | FTP | other *** search
- Path: 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
-
- 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.
-
-