Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
rump and htonl() in constants
The surprise is that when building rump, gcc complains with:
/usr/src/sys/rump/net/lib/libnet/../../../../net/route.c:1010:21: error: initializer element is not constant
static const struct in_addr inmask32 = {.s_addr = INADDR_BROADCAST};
^
/usr/src/sys/rump/net/lib/libnet/../../../../net/route.c:1010:21: error: (near initialization for 'inmask32.s_addr')
which certainly looks constant. Problem is that INADDR_BROADCAST may
contain a call to htonl(), e.g. try
========================================================================
#include <sys/endian.h>
#include <stdio.h>
#include <stdlib.h>
struct x {unsigned int y;};
static const struct x xx = {.y = (unsigned int)htonl(0xffffffff)};
int main()
{
printf("0x%x\n", xx.y);
return 0;
}
========================================================================
Given that 0xffffffff is the same in either order, there is an obvious
kludge, but any thoughts on an elegant solution?
Cheers,
Patrick
Home |
Main Index |
Thread Index |
Old Index