<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>union Problem</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/20047/union-problem</link><description> i am using the following union in a program. 
when i changes any of _74HC259 member field(Address,Data,Gate,Clear), variable Value doesn&amp;#39;t changes crosspondingly. 
 
union LATCH{ 
	unsigned char Value; 
	struct { 
 unsigned Address:3; 
 unsigned Data</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: union Problem</title><link>https://community.arm.com/thread/74087?ContentTypeID=1</link><pubDate>Tue, 06 Jun 2006 06:24:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:829799c8-e9af-47b3-833d-a9a65ec0b29b</guid><dc:creator>Ahmad  Kamal Nasir</dc:creator><description>&lt;p&gt;Because it doesn&amp;#39;t help to improve the readability of code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: union Problem</title><link>https://community.arm.com/thread/46168?ContentTypeID=1</link><pubDate>Sun, 04 Jun 2006 01:03:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d64404e1-37d5-4385-9a78-d9ea1694c096</guid><dc:creator>Neil Kurzmam</dc:creator><description>&lt;p&gt;It is an 8052.&lt;br /&gt;
&lt;br /&gt;
why not use a bit addresable byte.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: union Problem</title><link>https://community.arm.com/thread/112116?ContentTypeID=1</link><pubDate>Sat, 03 Jun 2006 17:12:14 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c7b699ce-6355-411e-bef1-e74d9417e6dd</guid><dc:creator>Karl Hamsher</dc:creator><description>&lt;p&gt;It just occurred to me that my &lt;i&gt;narrowing&lt;/i&gt; what the Standard says to suit your &lt;i&gt;unsigned&lt;/i&gt; usage could be misleading.  The Standard actually says that a bitfield may have type &lt;i&gt;int&lt;/i&gt;, &lt;i&gt;unsigned int&lt;/i&gt;, or &lt;i&gt;signed int&lt;/i&gt;.  I was limiting my reply to &lt;i&gt;unsigned&lt;/i&gt; because you were using unsigned types, but my comment about &lt;i&gt;&amp;quot;nonstandard bitfield type&amp;quot;&lt;/i&gt; would apply to &lt;i&gt;signed char&lt;/i&gt; as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: union Problem</title><link>https://community.arm.com/thread/98152?ContentTypeID=1</link><pubDate>Fri, 02 Jun 2006 11:03:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:576fcf85-751d-48df-b9b7-ad3033135083</guid><dc:creator>Karl Hamsher</dc:creator><description>&lt;p&gt;The Standard specifies that bitfields are to be of the &amp;quot;unsigned&amp;quot; type, not &amp;quot;unsigned char&amp;quot; type.  However, many compilers, C51 included, allow for other types (e.g., unsigned char) to provide widths narrower than sizeof(unsigned).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: union Problem</title><link>https://community.arm.com/thread/74089?ContentTypeID=1</link><pubDate>Fri, 02 Jun 2006 00:02:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4b4ff6b8-dc0a-4eac-bc80-ae9ff6adbd51</guid><dc:creator>Ahmad  Kamal Nasir</dc:creator><description>&lt;p&gt;&amp;quot;Or use a nonstandard bitfield type:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
what do you mean?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: union Problem</title><link>https://community.arm.com/thread/46165?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2006 07:22:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a0c08d09-abd6-4477-bd62-fd7e28eee1fc</guid><dc:creator>Karl Hamsher</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;... does C51 comiler doesn&amp;#39;t handle such type of data structure?&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Change Value&amp;#39;s type:&lt;br /&gt;
&lt;pre&gt;union LATCH{
    unsigned Value;
    struct {
        unsigned Address :3;
        unsigned Data    :1;
        unsigned Gate    :1;
        unsigned Clear   :1;
    }_74HC259;
}Latch;&lt;/pre&gt;
Or use a nonstandard bitfield type:&lt;br /&gt;
&lt;pre&gt;union LATCH{
    unsigned char Value;
    struct {
        unsigned char Address :3;
        unsigned char Data    :1;
        unsigned char Gate    :1;
        unsigned char Clear   :1;
    }_74HC259;
}Latch;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>