[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] "test/regress_dns.c", line 618: error: void function cannot return value
On 06/18/2018 10:21 PM, Azat Khuzhin wrote:
"test/regress_dns.c", line 618: error: void function cannot return value
Hi,
This is due to too strict compilers that does not allow ...
I see this all the time. Code that never get thrown into the blender of
strict compliance mode checks for portability reasons. A lot of code is
polluted with gnuism extensions to a point where finally folks started
talking about "gnu99" or "gnu11" as a made up bong smoke cloud language:
see https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Standards.html#C-Language
By default, GCC provides some extensions to the C language that, on
rare occasions conflict with the C standard. ....
Use of the -std options listed above disables these extensions where
they conflict with the C standard version selected. You may also
select an extended version of the C language explicitly with
-std=gnu90 (for C90 with GNU extensions), -std=gnu99 (for C99 with
GNU extensions) or -std=gnu11 (for C11 with GNU extensions).
So just hand waving made up stuff that laughs in the face of the specs.
Also the CFLAGS that I used were in the "loving and forgiving" mode
whereas strict to the harsh specifications would have been c99 with -Xc
compliance flags. However even the super friendly gcc 8.1.0 rejects the
use of a void function trying to return a value. No lang spec flags :
$ /usr/local/gcc8/bin/gcc -m64 -c -o void_me.o void_me.c
void_me.c: In function 'no_ret_ever':
void_me.c:54:12: warning: 'return' with a value, in function returning void
return fprintf ( stdout, "sum may be %i\n", foo + bar );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void_me.c:53:6: note: declared here
void no_ret_ever( uint64_t foo, uint64_t bar ){
^~~~~~~~~~~
$
Where the void function being called was :
void no_ret_ever( uint64_t foo, uint64_t bar ){
return fprintf ( stdout, "sum may be %i\n", foo + bar );
}
So wrong is wrong and I have no idea how any good compiler accepts that.
Dennis
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.