Post
Topic
Board Development & Technical Discussion
Re: DragonFly BSD patches for bitcoind
by
Venkatesh Srinivas
on 07/08/2011, 16:06:25 UTC
>> char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };

>> g++ 4.4.5 on DragonFly disapproves; the constants are being narrowed from int -> char inside an array initializer.

>AFAIK the problem is not the narrowing from int to char (which is perfectly allowed if it fits). The problem is that plain "char" has undefined signedness in C (signed in most compilers these days). So values larger than >0x80 throw an overflow warning. The correct thing would be to use "unsigned char" or uint8_t.

You're right; I misunderstood the error message:

main.cpp:1773: error: narrowing conversion of '249' from 'int' to 'char' inside { }

unsigned char would be correct.

It also turns out that the SO_NOSIGPIPE issue affects NetBSD and OpenBSD, both of which don't have SO_NOSIGPIPE, but do define BSD. So none of the issues are DragonFly specific.