From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9118 invoked by alias); 27 Jan 2011 06:35:28 -0000 Received: (qmail 9108 invoked by uid 22791); 27 Jan 2011 06:35:27 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Jan 2011 06:35:22 +0000 Received: from wpaz9.hot.corp.google.com (wpaz9.hot.corp.google.com [172.24.198.73]) by smtp-out.google.com with ESMTP id p0R6ZJQq009074 for ; Wed, 26 Jan 2011 22:35:19 -0800 Received: from iwn2 (iwn2.prod.google.com [10.241.68.66]) by wpaz9.hot.corp.google.com with ESMTP id p0R6YRs2032244 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Wed, 26 Jan 2011 22:35:17 -0800 Received: by iwn2 with SMTP id 2so1827917iwn.35 for ; Wed, 26 Jan 2011 22:35:17 -0800 (PST) Received: by 10.42.169.133 with SMTP id b5mr1683877icz.189.1296110117423; Wed, 26 Jan 2011 22:35:17 -0800 (PST) Received: from coign.google.com (adsl-71-133-8-30.dsl.pltn13.pacbell.net [71.133.8.30]) by mx.google.com with ESMTPS id c4sm12206858ict.7.2011.01.26.22.35.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 26 Jan 2011 22:35:16 -0800 (PST) From: Ian Lance Taylor To: Robert Dell Cc: gcc-help@gcc.gnu.org Subject: Re: warning: incompatible implicit declaration of built-in function 'malloc' References: <4D410614.8010107@mac.com> Date: Thu, 27 Jan 2011 06:35:00 -0000 In-Reply-To: <4D410614.8010107@mac.com> (Robert Dell's message of "Thu, 27 Jan 2011 00:43:48 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-System-Of-Record: true 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/msg00388.txt.bz2 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