Re: CLANG versus GCC question: compiling non-c99 code with CLANG (clang dumps error)

From: O. Hartmann <ohartman_at_zedat.fu-berlin.de>
Date: Mon, 24 Sep 2012 13:45:53 +0200
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:
>>
>> -- 
>> my_func(win)
>> Window win;
>> {
>>     [...]
>>     if ( current->win.data == (lux_data *)NULL ) return;
>>     [...]
>> }
>> -- 
>>
>> 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.
> 
> 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 sure
> the committees managed to ditch it in C11...

I see, I though this might be the case ... old, old, very old ...

> 
> 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 ... ?

> 
> 
>> 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.
>>
>> I tried to apply "CFLAGS+= -std=[c89|gnu89]" when compiling with CLANG
>> since GCC defaults to gnu89 while CLANG defaults to c99 standard, but
>> this didn't help.
> 
> 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 == (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 == (lux_wins *)NULL ) return;







Received on Mon Sep 24 2012 - 09:46:06 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:30 UTC