Why must butfields sum to a multiple of a byte?

Ali Çehreli acehreli at yahoo.com
Mon Jul 30 10:01:11 PDT 2012


On 07/30/2012 09:44 AM, Andrej Mitrovic wrote:
 > On 7/30/12, Ali Çehreli<acehreli at yahoo.com>  wrote:
 >> It is inherently unportable because unlike D, bitfields in C and C++
 >> give too much freedom to the compiler. The compiler can move the fields
 >> around at will.
 >
 > I really need to figure out a reliable way to extract this
 > information, at least for the target platform a library is compiled
 > on.

The program should be able to detect the placements of the fields. You 
can expect a certain bit pattern for a given set of values of the bit 
fields, set those values, read them on the D side, detect potential 
inconsistencies, and fail the execution (or hopefully compilation).

Ali



More information about the Digitalmars-d-learn mailing list