Date: Mon, 20 Jun 2011 14:44:39 -0500 From: Stephen Montgomery-Smith <stephen@missouri.edu> To: Chuck Swiger <cswiger@mac.com> Cc: Niclas Zeising <niclas.zeising@gmail.com>, Roman Divacky <rdivacky@freebsd.org>, "freebsd-ports@freebsd.org" <freebsd-ports@freebsd.org> Subject: Re: [ANNOUNCE]: clang compiling ports Message-ID: <4DFFA327.3050402@missouri.edu> In-Reply-To: <B94EED31-5992-44E6-B72C-C37D4D7FEF0F@mac.com> References: <20110620153753.GA41541@freebsd.org> <4DFF73E3.5010405@gmail.com> <4DFF76C7.5070001@missouri.edu> <432743E3-272A-40F5-AF31-6C1805F620F3@mac.com> <4DFF9AE3.10609@missouri.edu> <B94EED31-5992-44E6-B72C-C37D4D7FEF0F@mac.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 06/20/2011 02:28 PM, Chuck Swiger wrote: > On Jun 20, 2011, at 12:09 PM, Stephen Montgomery-Smith wrote: >>> top_button_cross() probably should be declared as returning void. What's presumably happening is that it gets a default return type of int since it doesn't otherwise specify a return type, and then fails to have an explicit return, which is an error. >> >> Is a return with no value, from a function of type int, meant to be an error in K&R code? > > I don't believe so, but pure K&R didn't require compilers to perform any sanity checking of function return types. This led to all sorts of bugs, which is why lint was invented and why ANSI-C compilers do expect function prototypes and perform function return-type checking. > >> If so, I will change the code so that "return" becomes "return 0". >> >> Otherwise, I think the clang compiler should be changed so that this is a warning, not an error. Or at least an error that can be switched off with -Wno-return-type. >> >> I will say that I have no desire to put ansii patches into working K&R code. > > It sounds like you want Clang to support -traditional. > It explicitly does not do so, although there is a bug filed as: > > http://llvm.org/bugs/show_bug.cgi?id=4557 > > The best course is to convert K&R C code to C89/ANSI; failing that, perhaps use gcc for things which require -traditional instead of Clang (although GCC seems to be depreciating -traditional also). This is someone else's code in math/xppaut. I have no desire to write extensive patches to his code. It would be a nightmare to maintain. I'll go with "return 0". Stephen
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4DFFA327.3050402>