Date: Mon, 24 Sep 2012 13:45:53 +0200 From: "O. Hartmann" <ohartman@zedat.fu-berlin.de> To: Dimitry Andric <dimitry@andric.com> Cc: Current FreeBSD <freebsd-current@FreeBSD.org> Subject: Re: CLANG versus GCC question: compiling non-c99 code with CLANG (clang dumps error) Message-ID: <506047F1.7060804@zedat.fu-berlin.de> In-Reply-To: <50602D4E.1040304@andric.com> References: <50602990.2090408@zedat.fu-berlin.de> <50602D4E.1040304@andric.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?506047F1.7060804>