From owner-freebsd-current@FreeBSD.ORG Mon Sep 24 11:46:06 2012 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EDDD11065672 for ; Mon, 24 Sep 2012 11:46:05 +0000 (UTC) (envelope-from ohartman@zedat.fu-berlin.de) Received: from outpost1.zedat.fu-berlin.de (outpost1.zedat.fu-berlin.de [130.133.4.66]) by mx1.freebsd.org (Postfix) with ESMTP id A23CD8FC0A for ; Mon, 24 Sep 2012 11:46:05 +0000 (UTC) Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost1.zedat.fu-berlin.de (Exim 4.69) with esmtp (envelope-from ) id <1TG76y-002fiF-C2>; Mon, 24 Sep 2012 13:46:04 +0200 Received: from e178019000.adsl.alicedsl.de ([85.178.19.0] helo=thor.walstatt.dyndns.org) by inpost2.zedat.fu-berlin.de (Exim 4.69) with esmtpsa (envelope-from ) id <1TG76y-0001mf-80>; Mon, 24 Sep 2012 13:46:04 +0200 Message-ID: <506047F1.7060804@zedat.fu-berlin.de> Date: Mon, 24 Sep 2012 13:45:53 +0200 From: "O. Hartmann" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:15.0) Gecko/20120910 Thunderbird/15.0.1 MIME-Version: 1.0 To: Dimitry Andric References: <50602990.2090408@zedat.fu-berlin.de> <50602D4E.1040304@andric.com> In-Reply-To: <50602D4E.1040304@andric.com> X-Enigmail-Version: 1.4.3 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig28FC7AF1D64B54355AF0772D" X-Originating-IP: 85.178.19.0 Cc: Current FreeBSD Subject: Re: CLANG versus GCC question: compiling non-c99 code with CLANG (clang dumps error) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2012 11:46:06 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig28FC7AF1D64B54355AF0772D Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Am 09/24/12 11:52, schrieb Dimitry Andric: > On 2012-09-24 11:36, O. Hartmann wrote: >> I have a problem and I guess there is a simple solution - at least, I >> hope. >> >> I try to compile a "in spe" port which contains some C code that is >> definitely Kernighan & Ritchie standard like: >> >> --=20 >> my_func(win) >> Window win; >> { >> [...] >> if ( current->win.data =3D=3D (lux_data *)NULL ) return; >> [...] >> } >> --=20 >> >> There is no declaration of the return type of the function, I guess it= >> is implicitely void in older standards, but is treated as non void >> function in CLANG - and there the error comes in. >=20 > Declarations with no type default to int, the infamous "implicit int" > rule, which apparently is very hard to get rid of. :) I'm not even sur= e > the committees managed to ditch it in C11... I see, I though this might be the case ... old, old, very old ... >=20 > In any case, in very old C, the 'void' type did not exist; you simply > ignored the return value of such a function. Well, but noadays, the compiler, like CLANG, complains about a "return;" in a non-void function. I discovered only two places in the file in question, so applying "void" as a patch should do the workaround ... ? >=20 >=20 >> I can compile the code without any problems with GCC 4.6 - without any= >> change of compiling standard or anything like that, it simply compiles= =2E >> >> I tried to apply "CFLAGS+=3D -std=3D[c89|gnu89]" when compiling with C= LANG >> since GCC defaults to gnu89 while CLANG defaults to c99 standard, but >> this didn't help. >=20 > Unfortunately you did not post the actual error message. What was it? here it is: win.c:796:50: error: non-void function 'lux_freedata' should return a value [-Wreturn-type] if ( current->win.data =3D=3D (lux_data *)NULL ) return; ^ win.c:826:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] lux_freewins() ^~~~~~~~~~~~ win.c:831:40: error: non-void function 'lux_freewins' should return a value [-Wreturn-type] if ( windows =3D=3D (lux_wins *)NULL ) return; --------------enig28FC7AF1D64B54355AF0772D Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQEcBAEBAgAGBQJQYEf7AAoJEOgBcD7A/5N85rIIANeTCJU9i5igzW3yl5DGvzxs GwgUJbyZiOxF3dawUeIuAkQmrB0ad/490XKS2mf6/cr/DmDrnvK757Y9ovQS2Adi dpvoLP1aL6e+bQpGcBr9sWYDzTISKmEfRlVPHh3kP01VU8wnW1vEiDyuWMxWe23D bF7KNBExAb0iAkS8HSFtQ5bkcY9h1PnNx9xE64OgxL1OnzkaRQF5Rd4S1cdTs2WW NX9eDq6fTmcNPYw9ci0+xbBktDJ0WGKU5wiJtJeiR2g1yo0LxgBuUPx8gUMDh3DR hKWtnkBqJnxrVqY2lrWTDLSMIJoR3Mi+Ubk7c+rkWFEx/22Y1fk46GJC+O7/ssk= =p+Oc -----END PGP SIGNATURE----- --------------enig28FC7AF1D64B54355AF0772D--