From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19967 invoked by alias); 27 Jan 2011 13:18:25 -0000 Received: (qmail 19885 invoked by uid 22791); 27 Jan 2011 13:18:24 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from asmtpout018.mac.com (HELO asmtpout018.mac.com) (17.148.16.93) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Jan 2011 13:18:18 +0000 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII; format=flowed Received: from nameserver.local ([24.29.193.138]) by asmtp018.mac.com (Oracle Communications Messaging Exchange Server 7u4-20.01 64bit (built Nov 21 2010)) with ESMTPA id <0LFO00K1INKAJW30@asmtp018.mac.com> for gcc-help@gcc.gnu.org; Thu, 27 Jan 2011 05:16:58 -0800 (PST) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.2.15,1.0.148,0.0.0000 definitions=2011-01-27_05:2011-01-27,2011-01-27,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=6.0.2-1012030000 definitions=main-1101270044 Message-id: <4D41706B.2040903@mac.com> Date: Thu, 27 Jan 2011 13:18:00 -0000 From: Robert Dell User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.23) Gecko/20090823 SeaMonkey/1.1.18 To: Ian Lance Taylor Cc: gcc-help@gcc.gnu.org Subject: Re: warning: incompatible implicit declaration of built-in function 'malloc' References: <4D410614.8010107@mac.com> In-reply-to: X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-01/txt/msg00397.txt.bz2 Ian Lance Taylor wrote: > Robert Dell writes: > > >> can somebody please explain why I'm getting this warning? >> warning: incompatible implicit declaration of built-in function 'malloc' >> >> char *returnval = 0; >> long outputBytes = 0; >> ... outputBytes gets changed and tested to ensure it's valid (non zero) ... >> >> the offending line is here. >> returnval = (char *) malloc(outputBytes + 2); >> > > You are calling the malloc function, but you have not declared it. That > means it gets the type "extern int malloc();". Since you are compiling > in hosted mode (the default), gcc knows that that declaration is > incorrect, and it is warning about that (the correct declaration is > "extern void *malloc(size_t);"). > > Typically this is fixed by adding > > #include > > to the start of your file. > > Ian > > see? i thought it would be something simple, that fixed it. thanks.