From owner-freebsd-questions@FreeBSD.ORG Mon Oct 25 15:41:57 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C1FC716A4CE for ; Mon, 25 Oct 2004 15:41:57 +0000 (GMT) Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.87]) by mx1.FreeBSD.org (Postfix) with ESMTP id A9EC943D66 for ; Mon, 25 Oct 2004 15:41:57 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from mac.com (smtpin08-en2 [10.13.10.153]) by smtpout.mac.com (Xserve/MantshX 2.0) with ESMTP id i9PFfueR002097; Mon, 25 Oct 2004 08:41:57 -0700 (PDT) Received: from [10.1.1.245] (nfw2.codefab.com [199.103.21.225] (may be forged)) (authenticated bits=0)i9PFftNG001414; Mon, 25 Oct 2004 08:41:56 -0700 (PDT) In-Reply-To: <417D18DF.1040607@u4eatech.com> References: <417D18DF.1040607@u4eatech.com> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <65CE1486-269C-11D9-9067-003065ABFD92@mac.com> Content-Transfer-Encoding: 7bit From: Charles Swiger Date: Mon, 25 Oct 2004 11:41:54 -0400 To: Richard Williamson X-Mailer: Apple Mail (2.619) cc: freebsd-questions@freebsd.org Subject: Re: odd warning message from gcc under FreeBSD 4.10 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Oct 2004 15:41:57 -0000 On Oct 25, 2004, at 11:16 AM, Richard Williamson wrote: > Is this something known about, or: What am I missing? > > TIA, > rip > > PROBLEM: > > man strstr says: returns char * > test code throws warning on line 7: > test.c:7: warning: assignment makes pointer from integer \ > without a cast [ ...see previous message in thread for example C program... ] Using -Wall will help clarify the situation for you: 6-ns1% cc -Wall -o red red.c red.c:2: warning: second argument of `main' should be `char **' red.c: In function `main': red.c:7: warning: implicit declaration of function `strstr' red.c:7: warning: assignment makes pointer from integer without a cast red.c:9: warning: implicit declaration of function `printf' red.c:12: warning: control reaches end of non-void function In other words, you ought to add: #include #include ...to the top of your sample program so that the prototypes for strstr() and printf() are known. Otherwise, the compiler guesses that the return value for an unknown function is an int, or will fit into one. On platforms where sizeof(int) == sizeof(void *), your code will work fine. On platforms where that is not the case-- such as the so-called "LP64" architectures-- such code will break. -- -Chuck