Re: [cc65] bit-fields

From: <silverdr1wfmh.org.pl>
Date: 2009-08-30 13:31:20
On 2009-08-30, at 11:25, Ullrich von Bassewitz wrote:

>
> Ok, the compiler can do bit-fields since yesterday. If anybody dares  
> to test
> this feature, I would be glad about some feedback.
>

Looks like you did it! The emitted code seems also relatively compact.

One thing that cought my attention:

#include <stdio.h>

void main(void)
{
	struct foo
	{
		unsigned int bar0 : 1;
		unsigned int bar1 : 1;
		unsigned int bar2 : 1;
		unsigned int bar3 : 1;
	};

	struct foo bars;

	bars.bar0 = 0;
	bars.bar1 = 1;
	bars.bar2 = 0;
	bars.bar3 = 0;

	printf("\nSize of int = %d", sizeof(int));
	printf("\nResult = %04X\n", bars);
}

Gives:

Size of int = 2
Result = 00F2

Sure - I shouldn't bother much about the uninitialised part of the  
struct representation but am simply flagging that as it seems one byte  
is differently handled than the other - it makes me suspicious and  
possibly it might be worth checking for bugs there...

Regards,

-- 
SD!
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Aug 30 13:31:32 2009

This archive was generated by hypermail 2.1.8 : 2009-08-30 13:31:34 CEST