[ILUG] C question...
John P . Looney
valen at tuatha.org
Thu Sep 16 11:04:05 IST 1999
Yet another wierd C question. Why me ?
I'm trying to compile up the Netrek server, and on this line:
stats->di != htonl(pl->p_stats.st_di) ||
socket.c:766: invalid operands to binary &
So, it looks like it's expanding ntonl, and then barfing. In other code,
there is the line:
pkt.milliDI = htonl(1000 * ranks[i].di);
#else /* Unixware/IRIX requires explicit casts */
/* this next define will make the next more readable */
#define BAD_SVR4_HACKS_CAST(a,b) (unsigned long)( (long double)a * (long double)b )
pkt.milliDI = htonl( BAD_SVR4_HACKS_CAST( 1000, ranks[i].di ) );
I define'd BAD_SVR4_HACKS in the other stuff, to get it working, but there
are no such hacks in this other (failing) code. The odd thing is, that it
only fails when optimisations are turned on; could have something to do
# if __BYTE_ORDER == __LITTLE_ENDIAN && defined __OPTIMIZE__
# define ntohl(x) __bswap_32 (x)
# define ntohs(x) __bswap_16 (x)
# define htonl(x) __bswap_32 (x)
# define htons(x) __bswap_16 (x)
Urk. Any flags I can give the compiler, to get it to compile this ?
Microsoft. The best reason in the world to drink beer.
More information about the ILUG