Date: Thu, 19 Sep 1996 12:56:47 +1000 From: Bruce Evans <bde@zeta.org.au> To: brandon@glacier.cold.org, freebsd-hackers@freebsd.org Subject: Re: machine/endian.h: network byte order macros Message-ID: <199609190256.MAA23999@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>Compiling with '-Wall -pedantic' when using these macros (i.e. ntohs)
>gives the warning:
>
>net.c: In function `get_server_socket':
>net.c:129: warning: ANSI C forbids braced-groups within expressions
This warning is correct. ntohs() depends on gcc statement-expressions,
and statement-expressions aren't ANSI.
>Although trivial, the problem can be fixed by just removing '(' ')' from
>the outside of the macro, leaving '{' '}' there. This likely causes a
No, this just breaks the statement-expression. `foo = { bar; } is a
syntax error even in gcc. Adding __extension__ before the statement-
expression seems to work right.
>problem with how its used (as a function), which would then lead one to
>think perhaps it should just be a function? *shrug*
A (non-inline) function would be slower.
Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609190256.MAA23999>
