Re: [wmii] wmii-3.6-rc1

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Wed, 7 Feb 2007 11:42:43 +0100

On Wed, Feb 07, 2007 at 11:15:38AM +0100, Stefan Tibus wrote:
> On Tue, 6 Feb 2007 11:18:34 -0500 Kris Maglione wrote:
> > On Tue, Feb 06, 2007 at 03:46:30PM +0100, Stefan Tibus wrote:
> > >wmii/draw.c contains a "return something" within a void function
> > >at line 65.
> >
> > Yes, it returns a call to itself, which is itself a void function.
>
> Well, it still is in todays repository, so you probably didn't
> consider this a bug. However, "return something" within a void
> function is not ANSI-C and the Sun Compiler here just says "no".
> It's a compatibility issue (like they appeared in libixp some
> time ago) and should be fixed. (And it's a non-sense construction
> in my eyes: returning some nothing within a function that is
> supposed to not return anything.)
>
> I have replaced draw.c line 61
> return loadfont(...);
> by
> loadfont(...); return;
> here. And in mouse.c line 334
> if (...)
> return do_managed_move(...);
> has to be
> if (...)
> { do_managed_move(...); return; }
> then (or something like that).

I investigated into this issue reading some C specs and compiler
mailing lists. Actually

void
f() {
        printf("foo\n");
}

void
g() {
        return f();
}

is valid C++ code, but invalid C code. However gcc 3.3+ accepts
this (maybe even 2.95, haven't checked), but spits out
warnings/errors if the -ansi flag is in use. So at least, these
constructs can be considered unportable.

See http://david.tribble.com/text/cdiffs.htm#C99-return-void
for reference.

Regards,

-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361
Received on Wed Feb 07 2007 - 11:42:43 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 16:20:25 UTC