From owner-freebsd-questions Sun Jan 16 12:43:54 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mailhop1.nyroc.rr.com (mailhop1-0.nyroc.rr.com [24.92.226.120]) by hub.freebsd.org (Postfix) with ESMTP id CBDB615087 for ; Sun, 16 Jan 2000 12:43:48 -0800 (PST) (envelope-from leisner@rochester.rr.com) Received: from mailout2.nyroc.rr.com ([24.92.226.121]) by mailhop1.nyroc.rr.com (Post.Office MTA v3.5.3 release 223 ID# 0-59787U250000L250000S0V35) with ESMTP id com; Sun, 16 Jan 2000 15:41:20 -0500 Received: from mail2.nyroc.rr.com ([24.92.226.140]) by mailout2.nyroc.rr.com (Post.Office MTA v3.5.3 release 223 ID# 0-59787U250000L250000S0V35) with ESMTP id com; Sun, 16 Jan 2000 15:34:24 -0500 Received: from rochester.rr.com ([24.93.17.24]) by mail2.nyroc.rr.com (Post.Office MTA v3.5.3 release 223 ID# 0-53939U80000L80000S0V35) with ESMTP id com; Sun, 16 Jan 2000 15:40:44 -0500 Received: from soyata.home (IDENT:leisner@localhost [127.0.0.1]) by rochester.rr.com (8.9.3/8.8.5) with ESMTP id PAA10900; Sun, 16 Jan 2000 15:43:35 -0500 Message-Id: <200001162043.PAA10900@rochester.rr.com> X-Mailer: exmh version 2.1.0 09/18/1999 Reply-To: leisner@rochester.rr.com To: Alfred Perlstein Cc: "Alexey N. Dokuchaev" , freebsd-questions@FreeBSD.ORG, leisner@rochester.rr.com Subject: Re: (void)printf(); (Was: Re: simple c i/o question) In-reply-to: Your message of "Thu, 13 Jan 2000 03:02:36 PST." <20000113030235.Z9397@fw.wintelcom.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 16 Jan 2000 15:43:35 -0500 From: "Marty Leisner" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Most cases of casting things like printf is to shut up lint. IMHO this is very bad practice, you shouldn't have unneeded symbols. Just for a quick note, gcc -Wall -W (2.95.2) doesn't complain on this program: : leisner@soyata;cat foo.c #include int main(void) { printf("hello world\n"); exit(0); } I don't know if gcc has an option to flag this...but write uncluttered code. Marty Leisner Alfred Perlstein writes on Thu, 13 Jan 2000 03:02:36 PS T > * Alexey N. Dokuchaev [000112 23:54] wrote: > > On Wed, 12 Jan 2000, Naief BinTalal wrote: > > > > > On Wed, Jan 12, 2000 at 04:28:23PM +0000, Jonathon McKitrick wrote: > > > > > > > > I'm trying to write a hello world program. What is the output file for > > > > the console currently being displayed (in other words, the screen)? > > > > I've tried printf, and fprintf to stdout and stderr. > > > > > > #include > > > > > > int > > > main(void) > > > { > > > (void)fprintf(stdout,"Hello World\n"); > > > return 0; > > > } > > > > > > > While browsing thru the source code of almost anything in FreeBSD, I've > > noticed that (type)function(parameters); syntax. Why not just to write > > function(paramenters). Like in the prev example, what's wrong with simple > > printf(blahblah); but (void)printf(blahblah); ? > > Nothing really, it's my preference to only use void when I mean: > > "i know this function returns something that may be interesting, but frankly > I don't care at this point" > > using it for things like printf is a bit much, but it sort of let's the > next guy know that you didn't miss something. > > I also remember hearing that older compilers had an option to complain > about code that didn't do something with return values. > > -Alfred > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message